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

查看:51
本文介绍了使用 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天全站免登陆