JS JSON string to JSON object
// Convert a JSON-formatted string to a JSON object var t = json.parse (' {' Name ': 123} '
JSON object to JSON string
// an array of JSON objects. //Packjson is an array of objects = [ {"name": "Nikita", "Password": "1111"}, { "name": "Tony", "Password": "2222"}]; // json to stringvar s = json.stringify (packjson); // S is a string. alert (packjson[// Access Object array Packjson
JSON string to JSON object in Java and Get properties
Parse JSON format string for object
String jsonstring = "[" + "{\" author\ ": \" 7\ ", \" id\ ": 358,\" title\ ": \" japan\ ", \" Pictures\ ": [{\" description\ ": \" 001\ ", \" imgpath\ ": \"/cms/u/cms/www/201203/05150720ii68.jpg\ "},{\" description\ ": \" 002\ ", \ "imgpath\": \ "/cms/u/cms/www/201203/05150720ii67.jpg\"}],\ "path\": \ "Ip\"}, "+" {\ "author \ ": \" 8\ ", \" id\ ": 359,\" title\ ": \" China\ ", \" Pictures\ ": [{\" description\ ": \" 101\ ", \" imgpath\ ": \"/cms/u/cms/www/ 201203/111111111111.jpg\ "},{\" description\ ": \" 102\ ", \" imgpath\ ": \"/cms/u/cms/www/201203/222222222222.jpg\ "}],\ "path\": \ "Ip\"}] "; Jsonarray Array=Jsonarray.fromobject (jsonstring);if(Array.size () > 0) { for(inti = 0; I < array.size (); i++) {Jsonobject job= Array.getjsonobject (i);//Traverse Jsonarray System.out.println ("Author:" + job.get ("author"));//get the property values in each object } }
The Java object is converted to a JSON object and gets the JSON object properties
/** * Java objects are converted to JSON objects and get JSON object Properties * /= Jsonobject.fromobject (student); System.out.println (Jsonstu.tostring ()); System.out.println (Jsonstu.getjsonarray ("hobby"));
JSON objects into Java objects and get Java object properties
/** * JSON objects are converted to Java objects and get Java object Properties * /= (Student) Jsonobject.tobean (Jsonstu, Student. class ); System.out.println (Stu.getname ());
Converts a list of Java objects to a JSON object array and to a string
Jsonarray array == array.tostring ();
Convert a Java object to a JSON object
Jsonobject Object = Jsonobject.fromobject (invite);
put JSON the string is converted to JAVA Object Array
String personstr = "" = jsonarray.fromobject (personstr); List<InvoidPerson> persons = (list<invoidperson>) jsonarray.tocollection (JSON, Nvoidperson. Class
Code from the network
Java and JS Operation JSON