Android Json数据解析
发布日期:2021-09-28 18:45:52 浏览次数:9 分类:技术文章

本文共 1468 字,大约阅读时间需要 4 分钟。

package com.example.h3c.util;import java.util.ArrayList;import org.json.JSONArray;import org.json.JSONException;import org.json.JSONObject;import org.json.JSONTokener;import android.util.Log;import com.example.pickride.entity.PincheInfo;public class DataParser {    // {”pincheinfolist”:[{“username”:”王五”},{“telephone”:“xxxxxx”},{“destination”:“xxxxx”},{“location”:“xxx”},{“time”:“xxx”}]}    public static ArrayList
PincheInfoParser(String jsonStr) { ArrayList
pincheInfoArr = new ArrayList
(); try { JSONTokener jsonParser = new JSONTokener(jsonStr); JSONObject person = (JSONObject) jsonParser.nextValue(); JSONArray jsonArr = person.getJSONArray("pincheinfolist"); int length = jsonArr.length(); for (int i = 0; i < length; i++) {// 遍历JSONArray JSONObject oj = jsonArr.getJSONObject(i); PincheInfo pi = new PincheInfo(); pi.username = oj.getString("username"); pi.telephone = oj.getString("telephone"); pi.destination = oj.getString("destination"); pi.location = oj.getString("location"); pi.time = oj.getString("time"); pincheInfoArr.add(pi); } } catch (JSONException e) { Log.d(ConstantsTable.LOG_TAG, "DataParser: pincheInfo json error!"); e.printStackTrace(); } return pincheInfoArr; }}

转载地址:https://blog.csdn.net/h3c4lenovo/article/details/8128443 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Android 万能Get请求Json方法
下一篇:Android 定位

发表评论

最新留言

路过,博主的博客真漂亮。。
[***.116.15.85]2024年03月20日 15时35分57秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

mysql统计结果大于0时返回true_mysql表查询练习 2019-04-21
c语言对结构体排序中间变量,求助:c语言怎么实现结构体的排序? 总是弄不对啊... 2019-04-21
c语言宏定义只能在最前面吗,C语言宏定义注意事项 2019-04-21
android悬浮窗服务卡死,Android 悬浮窗兼容问题谈 2019-04-21
表格相关的html语言,HTML标记语言——表格标记 2019-04-21
web聊天界面html,PC端Web聊天界面+代码分享(HTML+CSS) 2019-04-21
cmake qt 添加路径 项目_CMake配置Qt工程 2019-04-21
使用python开发的软件协议_WEB开发——Python WSGI协议详解 2019-04-21
冰点下载器手机版apk_冰点文库下载器 2019-04-21
python信号采集代码_13行代码实现:Python实时视频采集(附源码) 2019-04-21
h5引入json_纯js直接引入json文件 2019-04-21
python格式化字符串总结_Python字符串处理方法总结 2019-04-21
python中true什么意思_python中的bool是什么意思 2019-04-21
jacobian 矩阵意义_Jacobian矩阵和Hessian矩阵的作用是什么? 2019-04-21
c++ jna 数据类型_JNA 使用总结 2019-04-21
python中如何遍历列表并将列表值赋予_python中如何实现遍历整个列表? 2019-04-21
apache php mysql架构图_Apache+PHP+MYSQL+Tomcat+JK架构设计技巧与应用实战 2019-04-21
mysql 2003错误 10055_MYSQL无法连接---提示10055错误 2019-04-21
mysql redis缓存层_redis实现缓存的两种方式 2019-04-21
mysql索引篇_MySQL索引篇 2019-04-21