JSON data format { "list": [ { "Ann_type_name ": " Mail ", " Anne_name ": " Plugin.png ", "Anne_path": "/jscdc/upload/eamil/plugin.png", "userid": "11e4-e6a3-4bcea910-a76f-9f966c0d602a" }, { "Ann_type_name": "Mail", "Anne_name": "Act_6.gif", "Anne_path": "/jscdc/upload /eamil/act_6.gif ", " userid ": " 11e4-e6a3-4bcea910-a76f-9f966c0d602a " } ]} parsing code: string string= "{\" list\ ": [{\" ann_type_name\ ": \" mail \ ", \" Anne _name\ ": \" plugin.png\ ", \" anne_path\ ": \"/jscdc/upload/eamil/plugin.png\ ", \" userid\ ": \" 11e4-e6a3-4bcea910-a76f-9f966c0d602a\ "},{\" ann_type_name\ ": \" mail \ ", \" anne_name\ ": \" Act_6.gif\ ", \" anne_path\ ": \"/jscdc/upload/eamil/act_6.gif\ ", \" userid\ ": \" 11e4-e6a3-4bcea910-a76f-9f966c0d602a\ "}]}"; Jsonobject jsonobject = jsonobject.fromobject (string); //converts a JSON-formatted string into a JSON object//string reString = (String) jsonobject.get ("Arg1"); Jsonarray jsonarray = jsonobject.getjsonarray ("list"); //takes out the "root" array inside the JSON object, and converted into Jsonarray object Iterator<jsonarray> itr = jsonarray.iterator (); // Iterative Jsonarraywhile (Itr.hasnext ()) { JSONObject temp = Jsonobject.fromobject (Itr.next ()); publicanne publicanne = New publicanne (); publicanne.setannename (temp.getstring ("Anne_name")); publicanne.setannepath (temp.getstring ("Anne_path")); &nbsP; publicanne.setanntypeid (mailid); Publicanne.setanntypename (temp.getstring ("Ann_type_name")); publicanne.setuserid ( Receiveralluserids); this.cdcdao.createmodel (Publicanne); }
Jsonobject parsing JSON data for list<map>