相关疑难解决方法(0)

如何在嵌套的JSON结果中解析动态JSON密钥?

我有以下格式的JSON结果,JSON Lint将其显示为"有效响应".

我的问题是:如何访问"question_mark"的内容,因为"141","8911"等都是动态值?

我的示例代码用于访问"product"的值.

//Consider I have the first <code>JSONObject</code> of the "search_result" array and 
//I access it's "product" value as below.
String product = jsonObject.optString("product"); //where jsonObject is of type JSONObject.
//<code>product<code> now contains "abc".
Run Code Online (Sandbox Code Playgroud)

JSON:

{
 "status": "OK",
 "search_result": [

            {
                "product": "abc",
                "id": "1132",
                "question_mark": {
                    "141": {
                        "count": "141",
                        "more_description": "this is abc",
                        "seq": "2"
                    },
                    "8911": {
                        "count": "8911",
                        "more_desc": "this is cup",
                        "seq": "1"
                    }
                },
                "name": "some name",
                "description": "This is …
Run Code Online (Sandbox Code Playgroud)

java android json

51
推荐指数
2
解决办法
7万
查看次数

标签 统计

android ×1

java ×1

json ×1