当前位置:网站首页>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
边栏推荐
- Knowledge about the determination coefficient R2 and the relationship with the correlation coefficient
- Electron
- A solution to the problem that the display of newff function in neural network cannot be converted from double to struct
- 备战数学建模32-相关性分析2
- Caelus - full scene offline mixed Department solution
- 数学建模经验分享:国赛美赛对比/选题参考/常用技巧
- Experience sharing of mathematical modeling: comparison between China and USA / reference for topic selection / common skills
- Question bank and answers of the latest Guizhou construction eight (Mechanics) simulated examination in 2022
- Formal parameters vs actual parameters
- GDAL grid data types and their type codes
猜你喜欢

Hands on data analysis unit 3 model building and evaluation

Sword finger offer 09.30 Stack

ThreadLocal giant pit! Memory leaks are just Pediatrics

ThreadLocal巨坑!内存泄露只是小儿科...

array

从Celsius到三箭:加密百亿巨头们的多米诺,史诗级流动性的枯竭

Build your own PE manually from winpe of ADK

Gartner 2022 Top Strategic Technology Trends Report

Common controls and custom controls

Pychar remotely connects to the server to run code
随机推荐
C language | Consortium
windows版MySQL软件的安装与卸载
From Celsius to the three arrows: encrypting the domino of the ten billion giants, and drying up the epic liquidity
Niuke challenge 53:c. strange magic array
服务器创建虚拟环境跑代码
9项规定6个严禁!教育部、应急管理部联合印发《校外培训机构消防安全管理九项规定》
DOS command
ArcGIS secondary development - arcpy delete layer
Sword finger offer 15.65.56 I 56Ⅱ. Bit operation (simple - medium)
Build your own PE manually from winpe of ADK
工作上对金额价格类小数点的总结以及坑
Leaflet load day map
GDAL multiband synthesis tool
Hard (magnetic) disk (II)
GDAL and opencv smooth and blur TIF images
SwiftUI找回丢失的列表视图(List)动画
D - Face Produces Unhappiness
Complete diagram / Euler loop
How to personalize VIM editor format (DIY)
备战数学建模32-相关性分析2