java - 在 Java AndroidStudio 中读取数组的 JSON 文件
问题描述
我正在尝试从 AndroidStudio 中的 JSON 文件中读取数据,格式如下:
{
"records": [
[1,"name1","1,9"],
[2,"name2","0,74"],
...
]}
我想要包含 int、String、String 的对象(每行的新对象)。有人知道怎么写吗?
解决方案
这可能会有所帮助
JSONObject jsonObject ;// your json body
try {
JSONArray jsonArray = jsonObject.getJSONArray("records");
for (int i = 0; i < jsonArray.length(); i++) {
JSONArray jArray = jsonArray.getJSONArray(i);// for each row in records([2,"name2","0,74"])
}
} catch (JSONException e) {
e.printStackTrace();
}
推荐阅读
- r - R中的多轴重叠绘图(问题)
- mapbox - Mapbox iOS:Clusterproperties NSExpression all & any 不工作
- sharepoint-online - Sharepoint Online 搜索未完全重新抓取
- javascript - 如何将经典的 reactjs 转换为钩子?
- javascript - 当 URL 具有导航选项卡 ID 时,我想添加和删除类
- node.js - 我在使用 npm i 和 node_modules 时遇到错误
- spring - Heroku 显示 Whitelabel 错误页面,但不在本地主机上
- laravel - 如何在 crontab 中再添加一个命令?
- mysql - 通过使用 sequelize v5 解码 base64 来保存图像 blob
- node.js - 如何在 MongoDBStore 类中使用身份验证选项