开发者

SBJson and escaping string.

开发者 https://www.devze.com 2023-03-23 20:22 出处:网络
NSURL *url = [NSURL URLWithString:@\"http://localhost/News\"]; NSString *jsonString 开发者_运维技巧= [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
NSURL *url = [NSURL URLWithString:@"http://localhost/News"];
NSString *jsonString 开发者_运维技巧= [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];

NSLog(@"%@", jsonString);
NSDictionary *news = [jsonString JSONValue];

I get error when I try parse string to dictionary. (-JSONValue failed. Error is: Token 'string' not expected before outer-most array or object) and string "jsonString" in console is "[{\"ID\":1,\"Title\":\"First News\",\"Description\":\"First News\",\"ModifiedDate\":\"\/Date(1296597600000+0200)\/\",\"Images\":null}]"

How I can remove backslash?


Your JSON is not properly formatted, you are getting bad JSON. Please don't implement any remove backslash algorithm. Try to work on the web service which is sending this crap JSON.

0

精彩评论

暂无评论...
验证码 换一张
取 消