Project requirements need to be transmitted in JSON format to the background
Turn the dictionary into JSON
Addgoodmodel*model = _dataarray[i];
nsmutabledictionary*guigedict =[nsmutabledictionary dictionary];
[Guigedict setValue: Model. Name forkey:@ "name"];
[Guigedict setValue: Model. Isck forkey:@ "isck"];
[Guigedict setValue:groupprice forkey:@ "Groupprice"];
[Guigedict setValue: Model. Price forkey:@ ' price '];
[Guigedict setValue: Model. Storage Forkey:@ "Storage"];
[Guigedict setValue: [nsstring stringwithformat:@ '%ld ', model. Addgoodid] forkey:@ "id"];
[Guigedict setValue: Model. Commonid forkey:@ "Commonid"];
nsdictionary*parameter [Email protected]{@ "": [[NSString alloc]initwithdata:[nsjsonserialization DataWithJSONObject : Guigedict options:nsjsonwritingprettyprinted Error:nil] encoding:nsutf8stringencoding]};
Caveats: dictionaries cannot be
[Guigedict setobject:@ "" forkey:@ ""]; method, or it will appear garbled.
The array turns into JSON
The array can only be turned into JSON as a string, note that it cannot be a mutable array, only an immutable group
, or there will be a problem
nsarray*jsonarray =[nsarray arraywitharray:_newarray];
nsstring*string =[jsonarray jsonstring];
Note: After receiving the converted JSON format data must receive the assignment with the appropriate type, otherwise the data type does not crash
The array in iOS, the dictionary into JSON format uploaded to the background, problems encountered