Reputation: 1008
NSString removes the backslashes from the JSON. I'm eventually passing the variable into another javascript function that JSON.parses it. Because the backslashes are removed, the JSON.parse is failing.
JSON = "[\"test\"]"
NSString = "[test]" (Stored as)
JSON.parse(NSString) -> fails
Upvotes: 1
Views: 116
Reputation: 1874
use it
NSString* str=[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:@[JSON] options:0 error:nil] encoding:NSUTF8StringEncoding];
Upvotes: 1
Reputation: 1008
NSData * jsonData = [NSJSONSerialization dataWithJSONObject:@[JSON] options:0 error:nil] encoding:NSUTF8StringEncoding];
NSString * jsonString = [[NSString alloc] initWithData: jsonData];
This worked for me.
Upvotes: 1