If there is a string in JSON format
NSString *jsonstr =@"{ "Api": "Ccf.cart2.queryPointsBalance", "Code":"1", "v":"1.0", "msg":"", "Data": { "totalbalancequantity":"4", "Totalbalanceamt":"0.04", "Errorinfos": { "ErrorCode":"", "errormessage":"" } }}";
Direct conversions are problematic and must be escaped first (you can go to the JSON site). Written
@" {\"api\": \ "ccf.cart2.querypointsbalance\", \ "code\": \ "1\", \ "v\": \ "1.0\", \ "Msg\" : \ "\", \ "data\": {\ "totalbalancequantity\": \ "4\", \ "totalbalanceamt\": \ "0.04\", \ "Errorinfos\": {\ "errorcode\": \ "\" , \ "errormessage\": \ "\"}}"*data =*tempdictquerydiamond = [nsjsonserialization Jsonobjectwithdata:data options:0 Error:nil];
The Tempdictquerydiamond is then printed as
{API="ccf.cart2.queryPointsBalance"; Code=1; Data={Errorinfos={ErrorCode=""; ErrorMessage=""; }; Totalbalanceamt="0.04"; Totalbalancequantity=4; }; Msg=""; V="1.0";}
NSString converted to Nsdictionary