fastjson --JSONObject 和JSONArray 转换
fastjson解析:
resultValue=
[
{
"total": 1,
"saleLists": [
{
"categoryInfo": "测试父分类",
"id": 12,
"vendor_code": 0,
"brandInfo": "非龙品牌,",
}
]
}
]
第一步:解析完成以后 {"total": 1,"saleLists": [{"categoryInfo": "测试父分类","id": 12,"vendor_code": 0,"brandInfo": "非龙品牌,",}]}
JSONObject js=JSON.parseObject(JSON.parseArray(resultValue).get(0).toString());
第二步:解析完成后 [{"categoryInfo": "测试父分类","id": 12,"vendor_code": 0,"brandInfo": "非龙品牌,",}]
JSONArray js2=JSON.parseArray(js.getString("saleLists").toString());
第三步:解析完成后 {"categoryInfo": "测试父分类","id": 12,"vendor_code": 0,"brandInfo": "非龙品牌,",}
JSONObject jsObj2=JSON.parseObject(js2.get(0).toString());
第四步:js2jsObj2.getString("id"),得到12
fastjson --JSONObject 和JSONArray 转换的更多相关文章
- fastjson对json字符串JSONObject和JSONArray互相转换操作示例
2017-03-25 直接上代码: package com.tapt.instance; import com.alibaba.fastjson.JSON; import com.alibaba.fa ...
- fastjson如何判断JSONObject和JSONArray
1.fastjson如何判断JSONObject和JSONArray,百度一下,教程还真不少,但是是阿里的fastjson的我是没有找到合适的方法.这里用一个还算可以的方法,算是实现了这个效果. 网上 ...
- Fastjson, Gson, org.json.JSON三者对于JSONObject及JSONArray的判断
1.Fastjson 我们通常在已知格式的情况下直接使用JSONObject,JSONArray,但是如果遇到需要判断格式呢? try{ Object object = JSON.parse(a); ...
- [fastjson] - fastjson中 JSONObject 和 JSONArray
/** * 对jsonObject对象进行key的获取 * @param jsonObject */ public ArrayList<String> jsonKeyRecursion(J ...
- fastjson java类、字符串、jsonObject之前的转换
json对象转成json字符串 JSONObject json = new JSONObject(); json.put("page",1); json.put("pag ...
- fastjson之JSONObject、JSONArray
JSONObject,JSONArray是JSON的两个子类. 首先我们来看JSONObject源码: 会发现JSONObject是继承Map<String, Object>,并且都是使用 ...
- 探索RequestBody报com.alibaba.fastjson.JSONObject cannot be cast to xxx
今天使用RequestBody接受前端传过来的参数,以前接受字符串数组非常成功,这次把形参改成了List<User>,原本以为顺利接受参数并映射成User的list结构,结果竟然在我取us ...
- net.sf.json.JSONOBJECT.fromObject 与 com.alibaba.fastjson.JSONObject.parseObject
文章待补充,先写写以下知识点好了. NULL值处理之 net.sf.json.JSONObject 和 com.alibaba.fastjson.JSONObject区别 JSON作为一个轻量级的文本 ...
- Gson基本操作,JsonObject,JsonArray,String,JavaBean,List互转
(转自)https://www.cnblogs.com/robbinluobo/p/7217387.html String.JsonObject.JavaBean 互相转换 User user = n ...
随机推荐
- Vue.js学习笔记 第四篇 列表渲染
遍历数组和对象 和条件选择一样,循环也和其他语言类似,也尝试着用一个例子解决问题 <!DOCTYPE html> <html> <head> <meta ch ...
- html文件转换成pdf和word
1.html文件转成pdf 采用jar包有itext-asian.jar.itextpdf-5.5.5.jar.itext-pdfa-5.5.5.jar.itext-xtra-5.5.5.jar,为了 ...
- 为WebBrowser指定IE内核版本(MSIE 7.0)
.Web Browser Control – Specifying the IE Version http://www.west-wind.com/weblog/posts/2011/May/21/W ...
- mongodb 的安装(Centor OS )
1.下载地址 wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.2.tgz 2.解压.配置 tar zxvf mongodb ...
- spark学习2(hive0.13安装)
第一步:hive安装 通过WinSCP将apache-hive-0.13.1-bin.tar.gz上传到/usr/hive/目录下 [root@spark1 hive]# chmod u+x apac ...
- python-字符串应用
例1:用python程序将DNA的一条链翻译出来s1=’ATTACGGC‘ rule={'A':'T','T':'A','C':'G','G':'C'} s1='ATTACGGC' s2=[rule[ ...
- HIVE 配置文件详解
hive的配置: hive.ddl.output.format:hive的ddl语句的输出格式,默认是text,纯文本,还有json格式,这个是0.90以后才出的新配置: hive.exec.scri ...
- adb 解说
ADB是一个 客户端-服务器端 程序, 其中客户端是你用来操作的电脑, 服务器端是android设备. 先说安装方法, 电脑上需要安装客户端. 客户端包含在sdk里. 设备上不需要安装, 只需要在手机 ...
- 在Windows下使用adb logcat grep
在Windows下使用adb logcat grep 会提示 因为grep 为Linux命令,所以不能使用.怎么办呢? 这时候可以用到babun 下载地址:http://babun.github.i ...
- 解决:git warning: LF will be replaced by CRLF in xxxx
一. git add -A报错 在利用git add -A添加文件时,意外的发现报错了 报错信息中: LF:Line Feed 换行 CRLF:Carriage Return Line Feed 回 ...