将JSON字符串转换为Object

时间:2013-03-04 20:14:09

标签: iphone ipad

尝试将JSON字符串转换为对象

NSString *testString = @"OMJ=\"N.A.\"&SPJ=\"N.A.\"&OBJ=\"N.A.\"";

        NSMutableDictionary *tags = [NSMutableDictionary new];
        tags = [NSMutableDictionary dictionaryWithDictionary:[Utility convertJSONStringToObject:testString]];

错误消息!

-[__NSCFConstantString objectFromJSONString]: unrecognized selector sent to instance!

使用NSJSONSerialization后,字典JSON的retun值为空

         NSDictionary *JSON =
   [NSJSONSerialization JSONObjectWithData: [@"OMJ=\"N.A.\"&SPJ=\"N.A.\"&OBJ=\"N.A\"" dataUsingEncoding:NSUTF8StringEncoding]
                                        options: NSJSONReadingMutableContainers
                                         error: nil];

我在代码中做错了什么。任何人都建议我解决这个问题。

@thanks提前

0 个答案:

没有答案