Android --- Json解析
来源:互联网 发布:nginx 配置多目录访问 编辑:程序博客网 时间:2024/06/02 06:45
JsonObject ,描述大括号括起来的 json 内容
JSONObject obj = new JSONObject(jsonStr);// 获取一个 int 值int code = obj.optInt("code");// 获取字符串String name = obj.optString("name);// 获取 json 数组JSONArray ary = obj.optJSONArray("data");
JSONArray ,描述中括号括起来的内容
JSONArray ary = obj.optJSONArray("data");// 获取数组中的个数int len = ary.length();// 遍历内容for (int i = 0; i < len; i++) { // 按下标取出 json 对象 JSONObject articleJson = ary.optJSONObject(i); ...}
如果 json 数组中的内容都是字符串
String str = ["ABC","Hello","123"]JsonArray ary = new JsonArray(str);int len = ary.length();// 遍历内容for (int i = 0; i < len; i++) { String s = ary.optString(i); ...}
阅读全文
0 0
- 【json】android json解析
- Android-Android解析JSON
- Android数据解析:Json解析
- android---Json数据解析
- Android Json 数据解析
- android 解析JSON
- android 解析json数据格式
- android 解析json数据格式
- Android 解析json数据格式
- android 解析json数据格式
- android 解析json数据格式
- Android的JSON解析
- Android 解析Json
- android JSON 解析
- Android 解析json数据格式
- android解析Json
- Android解析json数据
- Android Json解析
- 一元线性同余方程简介
- 线段树
- 欢迎使用CSDN-markdown编辑器
- HDU 2680-Choose the best route-最短路+超级源点
- 《循序渐进》前端学习视频教程资料汇总
- Android --- Json解析
- 草稿
- 循环语句
- 42. Trapping Rain Water
- 数据结构与算法(Java描述)-17、递归转化成非递归算法以及迷宫算法
- 递归公式时间复杂度举例
- File Permissions and the chmod/chgrp/chown commands
- Ubuntu14.04+NVIDIA GTX 1050ti+cuda8安装
- Jzoj4791 矩阵