在方法中获取没有Arrayname的JSONArray

问题描述 投票:0回答:1

我需要从我的数据字符串中获取JSONArray但是没有提到如下的arrayname。它应该从JSON数据中获取Array name本身。

这是我的代码

            String metadata = result.getMetaData();
            JSONObject jsonObject = new JSONObject(metadata);

            JSONArray jsonArray = jsonObject.getJSONArray("Shoe2");

              for(int i =0 ; i<jsonArray.length();++i) {
                JSONObject rec = jsonArray.getJSONObject(i);
                barcode = rec.getString("BarcodeId");
                material=rec.getString("Material");
                category=rec.getString("Category");

            }
            Baroode.setText(barcode);
            Material.setText(material);
            Category.setText(category);

现在我需要的是自己获取JSON arrayname“SHoes1”,而不是像我这样使用显式命名。

我的JSON字符串看起来像这样

{
"Shoe2":[{
           "BarcodeId" : "9770012345673",
            "   " : "Men",
            "Material" : "Panther",
            "ProductId" : "ND-TR-0089",
            "ProductName" : "Black Retro"
        }
    ]
}

帮助将不胜感激:)

java android json vuforia
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.