当前位置:网站首页>Jsonobject jsonarray for parsing
Jsonobject jsonarray for parsing
2022-06-11 05:39:00 【Zippx.】
Bean Class resolution exception There are always a group of ** Make a mess of the interface Lead to bean Class is particularly rare Causes the programmer to crash Next, I will give you a detailed answer
1.JSONObject:
JSONObject It's just a data structure , It can be understood as JSON Format data structure (key-value structure ), have access to put Methods json Object to add elements .
JSONObject It can be easily converted into a string , You can also easily convert other objects into JSONObject object .
2.JSONArray:
JSONArray Is an ordered sequence of values . Its external text form is a string enclosed in square brackets , Separate values with commas .
The internal form has The object of the index get and opt Used to access values by index element Method , And methods for adding or replacing values .
3. When parsing interfaces, you will encounter interfaces with internal confusion , There are two kinds of errors in parsing this case : bean Class collection field error And inner classes are the forms of Chinese characters
4. In this case , You need to write an entity class manually according to the field :
Then create an entity class object :
Defining a string , The string content is the data in your interface :
What I recommend is Use JSONObject jsonArray Conduct Bean Class parsing processing First put the parsed data into a string And then through the JSONObject jsonArray Conduct json String parsing processing
5. View the data in the interface , If the field contains {} , That's it object, If it is [] That's it array Then parse the data and add it to the entity class
6. If you encounter any interface internal field problems in the future , Can use this method to solve , What this method needs to pay attention to is to add the data in the field to the entity class
There are two kinds of errors in parsing this case bean Class collection field error And inner classes are the forms of Chinese characters

The most effective solution Is to knock an entity class by hand According to the required fields Write entity classes This is more efficient 
What I recommend is Use JSONObject jsonArray Conduct Bean Class parsing processing
First put the parsed data into a string Inside the string 
And then through JSONObject jsonArray Conduct json String parsing processing 

Is to encounter all json String exception Or parse error You can use JSONObject jsonArray Conduct Bean Class parsing processing
边栏推荐
- Preliminary understanding of multi task learning
- Feynman learning method
- 2021-04-19
- Opencv learning path (2-3) -- Deep parsing imshow function
- QT Road (2) -- HelloWorld
- 微信小程序text内置组件换行符不换行的原因-wxs处理换行符,正则加段首空格
- How to apply for free idea with official documents
- Number of atoms (easy to understand)
- 如何让灯具智能化,单火、零火智能开关怎么选!
- NDK learning notes (VIII) thread related
猜你喜欢

Start the project using the locally configured gradle

GAMES101作业7-Path Tracing实现过程&代码详细解读

Preliminary understanding of DFS and BFS

String sorting times --- bubble sorting deformation

AltiumDesigner2020导入3D Body-SOLIDWORKS三维模型

数据接入平台方案实现(游族网络)

PCB走线到底能承载多大电流

Recherche sur l'optimisation de Spark SQL basée sur CBO pour kangourou Cloud Stack

es-ik 安装报错

袋鼠雲數棧基於CBO在Spark SQL優化上的探索
随机推荐
AttributeError: ‘HistGradientBoostingClassifier‘ object has no attribute ‘_ n_ features‘
35. search insertion position
code
MySQL circulates multiple values foreach, XML writing method
Solving graph problems with union search set
Metabase源码二次开发之Clojure 安装
mysql字符串转数组,合并结果集,转成数组
推荐一款免费的内网穿透开源软件,可以在测试本地开发微信公众号使用
Why is the smart door lock so popular? What about the smart door locks of MI family and zhiting?
Recommend a free intranet penetration open source software that can be used in the local wechat official account under test
Number of atoms (easy to understand)
SwiftUI: Navigation all know
Convert result set of SQL to set
微信小程序text内置组件换行符不换行的原因-wxs处理换行符,正则加段首空格
Es IK installation error
Topological sorting
NDK learning notes (14) create an avi video player using avilib+window
【项目篇- 附件佐证材料放什么?(十八种两千字总结)】创新创业竞赛项目计划书、挑战杯创业计划竞赛佐证材料
在未来,机器人或 AI 还有多久才能具备人类的创造力?
Gilde failed to go to the listener to call back the reason record when loading the Gaussian blur image