NSString json 车NSDictionary

NSData *jsonContent = [[userInfo
objectForKey:@"acme"]
dataUsingEncoding:NSUTF8StringEncoding];

NSDictionary *
jsonDic = nil;

NSError *error =
nil;

jsonDic = 
[NSJSONSerializationJSONObjectWithData:jsonContent
options:NSJSONReadingMutableLeaveserror:&error];

时间: 2024-10-28 13:59:37

NSString json 车NSDictionary的相关文章

NSDictionary 或者NSArray(NSMutableArray) ==>> NSData ==>> NSString (Json):

以下代码都有详细的注释说明这些类型之间的转换(如有错误的地方还望批评指出,谢谢!) - (void)viewDidLoad { [super viewDidLoad]; /** * NSDictionary ||NSArray(NSMutableArray) ==>> NSData ==>> NSString (Json): */ // NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys: // @&q

JSON TO NSDictionary Mac & iOS

NSString * jsonPath=[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Contents.json"]; NSString * jsonStr=[[NSString alloc] initWithData:[NSData dataWithContentsOfFile:jsonPath] encoding:NSUTF8StringEncoding]; NSLog(@"%

NSString+JSON - iOS

日常开发中常用的一个相互转换的方法; 直接创建对应的类,引用如下方法即可实现; 具体 code 如下: 声明: #import <Foundation/Foundation.h> @interface NSString (JSON) - (id)jsonObject; /** dic -> json*/ - (NSString *)dictionaryToJson:(NSDictionary *)dic; @end 实现: #import "NSString+JSON.h&qu

iOS NSDictionary &lt;--&gt; NSString(JSON) in Objc

NSDictionary --> NSString + (NSString*)stringINJSONFormatForObject:(id)obj { NSData *jsonData = [NSJSONSerialization dataWithJSONObject:obj options:0 // If that option is not set, the most compact possible JSON will be generated error:nil]; NSString

NSString,NSArray和NSDictionary to JSON标准格式字符串

#import <Foundation/Foundation.h> @interface NSString (HXAddtions) +(NSString *) jsonStringWithDictionary:(NSDictionary *)dictionary; +(NSString *) jsonStringWithArray:(NSArray *)array; +(NSString *) jsonStringWithString:(NSString *) string; +(NSStr

NSString转化为NSDictionary

如有一段json格式的字符串 NSString *jsonStr = @"{ "api": "ccf.cart2.queryPointsBalance", "code": "1", "v": "1.0", "msg": "", "data": { "totalBalanceQuantity": &q

iOS JSON、NSDictionary互转

#import "myCode.h" @implementation myCode /*! * @brief 把格式化的JSON格式的字符串转换成字典 * @param jsonString JSON格式的字符串 * @return 返回字典 */ + (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString { if (jsonString == nil) { return nil; } NSData *jsonD

iOS NSDictionary、NSData、JSON等 数据类型相互转换

1.NSDictionary类型转换为NSData类型: NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys: @"balance", @"key", @"remaining balance", @"label", @"45", @"value", @"USD", @"curre

NSData NSDate NSString NSArray NSDictionary 相互转化

//    NSData  NSDate NSString NSArray NSDictionary json NSString *string = @"hello word"; NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; NSArray *array = [NSArray arrayWithObjects:@"1",@"2",@"3",nil