jsonarray and jsonobject

 

 

        JSONArray ja = new JSONArray();
        ja.put("11");
        ja.put("22");
        ja.put("33");
        
        JSONArray ja2 = new JSONArray();
        ja2.put("aa");
        ja2.put("bb");
        
        ja.put(ja2);
        
        System.out.println(ja.toString());
// jsonarray which represents the set of the left and right []        
//				["11","22","33",["aa","bb"]]

        JSONObject jsonObject = new JSONObject();
        
        try {
        	
			jsonObject.put("aaa", "111");
	        jsonObject.put("bbb", "222");
	        jsonObject.put("ccc", "333");
	        jsonObject.put("ddd", "444");
	        
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        
        System.out.println(jsonObject.toString());
 // jsonObject is the middle of a: number, then the left and right sides are {}
//      {"ddd":"444","ccc":"333","bbb":"222","aaa":"111"}

  

 

Intelligent Recommendation

Add objects to JsonObject and JsonArray

Student class Test case Console: output...

Android JsonObject and JsonArray parsing

Example 1: JSON file program: Example two: program: JSON file Example three program:  ...

Fastjson's JSONArray and JSONObject

[Image upload failed... (image-6adce8-1522634020763)] What is JSON? JSON (JavaScript Object Notation) is a lightweight data exchange format. Easy for people to read and write. It is also easy to machi...

More Recommendation

JsonArray and JsonObject traversal methods

One: traverse JsonArray Two: traversing JsonObject...

List to JsonArray and JsonObject

Reference URL:  ...

JSONObject and JSONArray in json-lib

 Json-lib is used to complete the transformation of beans, collections, maps, java arrays, XML and JSON between jars, json-lib depends on several other jar packages (I tried all jars with the latest v...

springb2.0.4 in JSONObject and use JSONArray

First introduced jar package: JSONObject Usage: you may receive data format: { "id": "123", "courseID": "huangt-test", "title": "Submit Job"...

JSONObject and indiscriminate use of JSONArray

Recently, the company developed several projects in the background Action are Json format to the front-end data transfer, so to JSONObject, JSONArray simply study a little, ado, want to use JSONObject...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top