当前位置:网站首页>Understand the difference and use between jsonarray and jsonobject
Understand the difference and use between jsonarray and jsonobject
2022-06-26 14:30:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
One .JSONObject What is it? ? It's the object json; I knew it in seconds json Said in ,{} Representing objects , therefore JSONObject Namely :{“name”:”tom”} meanwhile , The object here Json By adding an array json Can become an array of objects json: {“name”:[“tome”,”kate”]} for example : JSONObject jsono = new JSONObject();
JSONArray jsona = new JSONArray();
jsona.put(“tom”);
jsona.put(“kate”);//[“tom”,”kate”]
jsono.put(“name”,jsona);//{“name”:[“tom”,”kate”]}
Two .JSONArray What is it? ? It's an array. json I knew it in seconds json Said in ,[] Represents an array , therefore JSONArray Namely [“tom”,”kate”,”jerry”]; perhaps [1,2,3] meanwhile , The array here json By adding objects json Can become an array object json: [{“name”:”tom”},{“name”:”kate”}] for example : JSONArray jsona = new JSONArray();
JSONObject jsono1 = new JOSNObject();
JSONObject jsono2 = new JSONObject();
jsono1.put(“name”,”tom”);//{“name”:”tom”} jsono2.put(“name”,”kate”);//{“name”:”kate”}
jsona.put(json1,json2);//[{“name”:”tom”},{“name”:”tom”}]
3、 ... and . The combination of the two can also generate object array objects json:{“book”:[{“name”:”harrypotter”},{“name”:”potterharry”}]} ① Create objects json->jsono1:{“name”:”harrypotter”}:jsona1.put(“name”,”harrypotter”); ② Create objects json->jsono2:{“name”:”potterharry”}:jsona2.put(“name”,”potterharry”); ③ Create array json->jsona:[{“name”:”harrypotter”},{“name”:”potterharry”}]:jsona.put(jsona1);jsona.put(jsona2); ④ Create objects json->jsono3:jsono3.put(“book”,jsona);
notes :JSONArray and JSONObject The first and most important difference in reuse is : JSONArray It is added one by one ; JSONObject It's one-on-one ;
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/133818.html Link to the original text :https://javaforall.cn
边栏推荐
- D - Face Produces Unhappiness
- One article of the quantification framework backtrader read observer
- Correlation analysis related knowledge
- Caelus - full scene offline mixed Department solution
- "Scoi2016" delicious problem solution
- ArcGIS cannot be opened and displays' because afcore cannot be found ' DLL, solution to 'unable to execute code'
- 量化框架backtrader之一文读懂observer观测器
- Lucky numbers in the matrix
- transformers DataCollatorWithPadding类
- MHA高可用配合及故障切换
猜你喜欢
随机推荐
datasets Dataset类(2)
How to convert data in cell cell into data in matrix
SwiftUI找回丢失的列表视图(List)动画
Hard (magnetic) disk (I)
Sword finger offer 21.57.58 I Double pointer (simple)
Notes: the 11th and 12th generation mobile versions of Intel support the native thunderbolt4 interface, but the desktop version does not
[sdoi2013] forest
Question bank and answers of the latest Guizhou construction eight (Mechanics) simulated examination in 2022
STM32F1和GD32F1有什么区别?
wptx64能卸载吗_win10自带的软件哪些可以卸载
Linear basis
ArcGIS secondary development - arcpy delete layer
Sword finger offer 18.22.25.52 Double pointer (simple)
Correlation of XOR / and
Sword finger offer 15.65.56 I 56Ⅱ. Bit operation (simple - medium)
Flex & Bison 开始
Two point answer, 01 score planning (mean / median conversion), DP
[hnoi2010] flying sheep
Sword finger offer 45.61 Sort (simple)
(improved) bubble sorting and (improved) cocktail sorting









