使用JSONArray或普通Array来存储/读取数据是否更有效率? [英] Is it more efficient to use a JSONArray or normal Array for storing/reading data?
问题描述
我正在使用一个连接到PHP/MySQL
服务器的应用程序,该服务器以JSON
格式返回所有内容.例如,用户列表以JSONObject
的JSONArray
的形式返回.每个对象都包含单个用户的信息(名称,位置,电话号码等).
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
和包含的对象中提取所有内容以首先构建常规的Array
或ArrayList
?
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 JSONArray
and 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屋!