记录json解析
来源:互联网 发布:馆陶县行知教育集团 编辑:程序博客网 时间:2024/06/06 02:58
一...
1. 使用jsonObject的时候需要注意.如果返回的json本身就是数组.则需要使用jsonArray,大括号属于对象,中括号属于数组
String jsonString ="{\"name\":\"zhangsan\",\"password\":\"zhangsan123\",\"email\":\"10371443@qq.com\"}";
"body": {
"datalist": [{
"fundchinesenm": "东海东风1号"
"aptm": "15:00:00"
"fee": "123.00"
},
{
"fundchinesenm": "东海东风1号",
"aptm": "150000",
"fee": "123.00",
}],
}
2.jsonObject的基本用法 JSONObject mjson = new JSONObject(jsonString);
string name = mjson.getString("name");
3.jsonObjectArray的基本用法 JSONObject mjson = new JSONObject("body"); //获取到json对象
JSONObjectArray mArray = mjson.getJSONArray("datalist"); //获取到数组
for(int i = 0;i = mArray.length();i++){
JSONObject mjo = mArray.getJSONObject(i);//获取到数组json里面的对应的值
String fundchinesenm = mjo.getString("fundchinesenm"); //取到值
};
二...
1. 使用gson解析数据.非常的简单,
Gson gson = new Gson();
Result result = gson.fromJson(jsonData, Result.class);
1. 使用jsonObject的时候需要注意.如果返回的json本身就是数组.则需要使用jsonArray,大括号属于对象,中括号属于数组
String jsonString ="{\"name\":\"zhangsan\",\"password\":\"zhangsan123\",\"email\":\"10371443@qq.com\"}";
"body": {
"datalist": [{
"fundchinesenm": "东海东风1号"
"aptm": "15:00:00"
"fee": "123.00"
},
{
"fundchinesenm": "东海东风1号",
"aptm": "150000",
"fee": "123.00",
}],
}
2.jsonObject的基本用法 JSONObject mjson = new JSONObject(jsonString);
string name = mjson.getString("name");
3.jsonObjectArray的基本用法 JSONObject mjson = new JSONObject("body"); //获取到json对象
JSONObjectArray mArray = mjson.getJSONArray("datalist"); //获取到数组
for(int i = 0;i = mArray.length();i++){
JSONObject mjo = mArray.getJSONObject(i);//获取到数组json里面的对应的值
String fundchinesenm = mjo.getString("fundchinesenm"); //取到值
};
二...
1. 使用gson解析数据.非常的简单,
Gson gson = new Gson();
Result result = gson.fromJson(jsonData, Result.class);
阅读全文
1 0
- json解析记录
- Python json解析记录
- 记录json解析
- Java解析json学习记录
- 【优秀框架记录】 json解析:GSON
- 记录 java 解析一个json数据
- 记录一下在Android使用Json解析字符串
- 【记录】c++实现json格式解析与转换
- 【JSON解析】JSON解析
- JSON 记录
- json记录
- 解析JSON
- Json解析
- JSON解析
- JSON解析
- json解析
- Json解析
- Json解析
- Understanding LSTM Networks
- 15213-BombLab 备忘
- Codeforces Round #435 (Div. 2) C. Mahmoud and Ehab and the xor
- C++数据结构实验报告:顺序表实现
- 1203:单词分割
- 记录json解析
- 表单标签
- Divide and Conquer -- Leetcode problem53. Maximum Subarray
- FreeRTOS 任务挂起和恢复
- 郵便実装
- 微服务架构特点
- MySQL备份之mysqldump工具--lock-all-tables
- ThinkPHP CURD之登录
- MATLAB 判断字符串中是否含有特定的字符