使用JSONArray或普通Array来存储/读取数据是否更有效率? [英] Is it more efficient to use a JSONArray or normal Array for storing/reading data?

查看:439
本文介绍了使用JSONArray或普通Array来存储/读取数据是否更有效率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个连接到PHP/MySQL服务器的应用程序,该服务器以JSON格式返回所有内容.例如,用户列表以JSONObjectJSONArray的形式返回.每个对象都包含单个用户的信息(名称,位置,电话号码等).

I'm working with an app that connects to a PHP/MySQL server from which everything is returned in JSON format. For example, a list of users is returned as a JSONArray of JSONObject. Each object contains the individual user's information (name, location, phone number, etc).

在使用这种格式的信息时,将所有内容保留为JSON格式并仅根据需要仅从数组/对象中提取项目的效率更高?还是最好先从JSONArray和包含的对象中提取所有内容以首先构建常规的ArrayArrayList?

In working with information in this format is is more efficient to leave everything in JSON format and only extract items from the array/objects as needed? Or is it better to extract everything from the JSONArrayand included objects to build a regular Array or ArrayList first?

推荐答案

JSONArray在内部使用ArrayList.它只是对ArrayList的包装.所以我说没有区别. JSONObject使用HashMap,因此也没有真正的缺点.

JSONArray internally uses ArrayList. It's just wrapper over ArrayList. So I'd say there is no difference. JSONObject uses HashMap so again no real drawbacks.

这篇关于使用JSONArray或普通Array来存储/读取数据是否更有效率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆