当前位置:网站首页>JSONObject解析json格式的终极总结
JSONObject解析json格式的终极总结
2022-07-25 09:27:00 【安卓世界库】
、、、、、、、、、、、、、解析json对象、、、、、、、
1.把json格式的字符串变成json对象。
jsonObject jsonObject = new JSONObject(resData);
2.分析resData顶层对象
a.如果根据键key获得值是数组,那么用
JSONArray basedata = jsonObject.getJSONArray("basedata");
从JSONArray数组取出一个内容用JSONArray 对象的getJSONObject(“key”);
b.如果根据键key获得值是字符串,那么用
String deviceName = jsonObject.getString("deviceName");
c.如果根据键key获得值是json对象,那么用
JSONObject jsonObject1 = basedata.getJSONObject(“key”);
d.其他依次同理,比如整数等。。
、、、、、、、、、、、、、、、、、、、、、、、赋值json对象方法。。。。。
JSONObject jsonObject = new JSONObject();
jsonObject.put("appId", "appId01");
jsonObject.put("globalId", xx);
StringEntity s = new StringEntity(jsonObject.toString(), "utf-8");
边栏推荐
- SQL 题目整理
- [recommended collection] with these learning methods, I joined the world's top 500 - the "fantastic skills and extravagance" in the Internet age
- VLAN的配置及其应用(以华为eNSP为例)
- ISP image signal processing
- 车辆属性最近一次入库时间初始化生成sql脚本文件
- [necessary for growth] Why do I recommend you to write a blog? May you be what you want to be in years to come.
- emmet语法速查 syntax基本语法部分
- shortest-unsorted-continuous-subarray
- 几个常用的网络诊断命令
- 【建议收藏】靠着这些学习方法,我入职了世界五百强——互联网时代的“奇技淫巧”
猜你喜欢
随机推荐
Reflection 反射
[deployment of deep learning model] deploy the deep learning model using tensorflow serving + tornado
CCF 201512-3 drawing
An ASP code that can return to the previous page and automatically refresh the page
The way of code neatness -- hit the pain point directly
字符串最长公共前缀
@Import,Conditional和@ImportResourse注解
安装 oh my zsh
VCs common commands
js数字千位分割的常用方法
线程池的死锁事件
多数相合问题总结
腾讯云之错误[100007] this env is not enable anonymous login
Qt 6.2的下载和安装
NPM详解
Pnpm Brief
SD/SDIO/EMMC
@Import, conditional and @importresource annotations
C3D模型pytorch源码逐句详析(三)
Introduction to arm GIC
![严重 [main] org.apache.catalina.util.LifecycleBase.handleSubClassException 初始化组件](/img/39/6f6760e80acec0b02028ea2ed1a5b1.png)








