I have a NSString with below format .Currently it is not a valid JSON string .I want to change it as a JSON string and store it in an NSArray.
This is my NSString.
[, {"Agent":" Visitor", "Time":"03:18 AM", "Message":"Msg from : file:///Users/satheesanop/Desktop/something.htmlIP Address : 182.72.139.142Country : IndiaCity : MadrasRegionName : Tamil N?duBrowser : Chrome 22OS : Mac", }, {"Agent":" agent name", "Time":"03:21 AM", "Message":"Thank you for contacting us.How may i help you ?", }, {"Agent":" Visitor", "Time":"03:22 AM", "Message":"Some message.", }]
Any help is appreciated .
You need to convert NSString to NSData using dataUsingEncoding: method.
then use the JSONObjectWithData method and add it to array.
NSArray *arrayJson = [NSArray arrayWithObjects:[NSJSONSerialization JSONObjectWithData:data options:0 error:nil],nil];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With