Detailed explanation of the differences between jsonobject and jsonarray in Java
In several recent projects developed by the company, the data transferred from the background action to the front end is in JSON format, so we simply studied jsonobject and jsonarray. There is no more nonsense. If you want to use jsonobject and jsonarray, the policy must have Commons lang.jar Commons beautils in the project jar commons-collections. jar commons-logging. jar ezmorph. jar json-lib-2.2. 2-jdk15. Jar these jar packages.
1. Differences between jsonobject and jsonarray;
2. Differences between jsonobject and jsonarray;
The creation method is different:
Jsonobject creation method:
Method created by jsonarray
Different acquisition methods
Example
result:
jsonObject1:{"UserName":"ZHULI","age":"30","workIn":"ALI"} jsonObject2:{"workIn":"ALI","UserName":"ZHULI"} jsonArray1:["ZHULI","30","ALI"] jsonArray2:["ZHULI","ALI"] jsonArray FROM HASHMAP:[{"workIn":"ALI","UserName":"ZHULI"}] jsonObject2:{"UserName":"ZHULI","workIn":"ALI","Array":["ZHULI","ALI"]}
3. Parse JSON string;
Return value:
UserName:kobi Array:kobi Array:34 Array:ALI
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.