Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Java AndroidStudio中读取数组的JSON文件_Java_Android_Json - Fatal编程技术网

在Java AndroidStudio中读取数组的JSON文件

在Java AndroidStudio中读取数组的JSON文件,java,android,json,Java,Android,Json,我正在尝试从AndroidStudio中的JSON文件读取数据,格式如下: { "records": [ [1,"name1","1,9"], [2,"name2","0,74"], ... ]} 我希望对象包含int、String、String(每行的新对象)。有人知道怎么写吗?这可能会有帮助 JSONObject jsonObject ;// your json bo

我正在尝试从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();
    }
JSONObject JSONObject;//您的json正文
试一试{
JSONArray JSONArray=jsonObject.getJSONArray(“记录”);
for(int i=0;i
这是否回答了您的问题?