学习JSONObject/JSONArray
来源:互联网 发布:matlab编程窗口 编辑:程序博客网 时间:2024/06/15 21:08
学习JSONObject/JSONArray
package test;import java.util.Map;import net.sf.json.JSONArray;import net.sf.json.JSONObject;/*关键词: * 1.JSONObject:json对象,{key:value} * 2.JSONArray:json数组,[{key:value},{key:value}] * 3.Json对象中添加的是键值对,JSONArray中添加的是Json对象 * 4.JSONObject与Map:map和json都是键值对,不同的是map中的每一对键值对是用等号对应起来的,而json中的每一对键值对是用冒号对应起来的. */public class TestJson { public static void main(String[] args) { String arrays="[{name1:{name2:{name3:'value1',name4:'value2'}}},{}]"; JSONArray getJSONArray=JSONArray.fromObject(arrays);//将结果转化成JSONArray对象 JSONObject getJsonObj =getJSONArray.getJSONObject(0);//获取json数组中的第一项 String result=getJsonObj.getJSONObject("name1").getJSONObject("name2").getString("name4"); System.out.println("取出name4的值: "+result); JSONObject jsonobject=new JSONObject();//json对象 jsonobject.put("key", "value"); JSONArray jsonarray=new JSONArray();//json数组 jsonarray.add(jsonobject); //其实json就是一种特殊形式的map。 Map<String,String> strmap=new JSONObject(); }}
0 0
- 学习JSONObject/JSONArray
- java 深入学习JSONObject、JSONArray
- JSONObject JSONArray
- JSONObject & JSONArray
- JSONObject、JSONArray
- JSONObject、JSONArray
- JSONObject JSONArray
- JSONObject/JSONArray
- JSONObject、JSONArray
- JsonObject&JSONArray
- JSONObject,JSONArray
- JSONObject、JSONArray
- JSONObject、JSONArray
- JsonObject、 jsonArray
- JSONObject、JSONArray
- JsonObject JsonArray
- JSONObject & JSONArray
- JSONObject、JSONArray
- 一、Clion 2017.2安装配置及CMakefile.txt初认识
- TLE
- Rex 远程执行命令
- redis链接池工具类
- Android 用SurfaceView+PLMediaPlayer 打造一个平板端的网络播放器
- 学习JSONObject/JSONArray
- 初识Eclipse
- 好消息,微软宣布HoloLens进入中国。
- JAVA基础-网络编程(09)
- lxml教程
- 使用 ngrok 让公网可以访问内网
- AndroidStudio 巧用 码云 + sourceTree 实现版本控制
- linux 源码包mysql
- 从Excel中导入数据到Neo4j