当前位置:网站首页>Jsonarray traversal
Jsonarray traversal
2022-07-28 16:55:00 【Zhengx Hui】
One . Requirements describe :
Need to put json Array JSONArray Object to traverse 、 Convert to List object

Two . Demand analysis :
1. The first thing I think of is direct traversal , adopt JSONObject Object to get the specified k Of v value
for (JSONObject a : jsonArray){
list.add(a.get("k"))
}But compilation exception , The display traversal object must be Object object , I was confused at that time ,json Array is not put json..
2. View source code :

What we achieve is List<Object> Method , drunk .....
3. Try forced transformation JSONObject, Report errors :
for (JSONObject a : jsonArray){
JSONObject x = (JSONObject) a
list.add(x.get("k"))
}3、 ... and . resolvent :
Object You need to turn first JSON, Then you can turn JSONObject:
JSON.toJSON

for (JSONObject a : jsonArray){
JSONObject x = (JSONObject) JSON.toJSON(a)
list.add(x.get("k"))
}perhaps :
List list = conditions.stream().map(obj -> {
JSONObject jsonObj = (JSONObject) JSON.toJSON(obj);
return jsonObj.getString("status");
}).collect(Collectors.toList());
边栏推荐
- 给定正整数N、M,均介于1~10 ^ 9之间,N <= M,找出两者之间(含N、M)的位数为偶数的数有多少个
- Interesting kotlin 0x06:list minus list
- Signal and slot mechanism of QT learning
- Multiple commands produce ‘.../xxx.app/Assets.car‘问题
- Leetcode daily practice - the number of digits in the offer 56 array of the sword finger
- Leetcode70 suppose you are climbing stairs. You need n steps to reach the roof. You can climb one or two steps at a time. How many different ways can you climb to the roof?
- 记录开发问题
- Introduction and implementation of stack (detailed explanation)
- FX3开发板 及 原理图
- 每一个账号对应所有密码,再每一个密码对应所有账号暴力破解代码怎么写?...
猜你喜欢

Quickly master kotlin set functions

小程序:获取元素节点信息

USB产品(FX3、CCG3PA)的调试方法

有趣的 Kotlin 0x07:Composition

【深度学习】:《PyTorch入门到项目实战》第二天:从零实现线性回归(含详细代码)

Ansa secondary development - build ansa/meta secondary development environment on pycharm

Leetcode daily practice - 160. Cross linked list

Call DLL file without source code

College students participated in six Star Education PHP training and found jobs with salaries far higher than those of their peers

Sort 4-heap sort and massive TOPK problem
随机推荐
排序4-堆排序与海量TopK问题
Leetcode learn to insert and sort unordered linked lists (detailed explanation)
Ruoyi集成flyway后启动报错的解决方法
关于MIT6.828_HW9_barriers xv6 homework9的一些问题
【从零开始学习SLAM】将坐标系变换关系发布到 topic tf
FX3开发板 及 原理图
Redis系列4:高可用之Sentinel(哨兵模式)
Microsoft question 100 - do it every day - question 16
Splash (渲染JS服务)介绍安装
【深度学习】:《PyTorch入门到项目实战》第一天:数据操作和自动求导
Ansa secondary development - two methods of drawing the middle surface
"Wei Lai Cup" 2022 Niuke summer multi school training camp 3 a.ancestor lca+ violence count
Wake up after being repeatedly upset by MQ! Hate code out this MQ manual to help the journey of autumn recruitment
Learn to use MySQL explain to execute the plan, and SQL performance tuning is no longer difficult
WSL+Valgrind+Clion
[JS] eight practical new functions of 1394-es2022
Debugging methods of USB products (fx3, ccg3pa)
QT designer for QT learning
我该如何理解工艺
About mit6.828_ HW9_ Some problems of barriers xv6 homework9