java解析嵌套json_Java 如何解析嵌套JSON结果中的动态JSON键?

有以下格式的JSON结果,JSON Lint将其显示为“有效响应”。

我的问题是:由于“ 141”,“ 8911”等都是动态值,我如何访问“ question_mark”的内容?

我的示例代码用于访问“产品”的价值。

//Consider I have the first JSONObject 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.

//product now contains "abc".

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 some product"

},

{

"product": "XYZ",

"id": "1129",

"question_mark": {

"379": {

"count": "379",

"more_desc": "this is xyz",

"seq": "5"

},

"845": {

"count": "845",

"more_desc": "this is table",

"seq": "6"

},

"12383": {

"count": "12383",

"more_desc": "Jumbo",

"seq": "4"

},

"257258": {

"count": "257258",

"more_desc": "large",

"seq": "1"

}

},

"name": "some other name",

"description": "this is some other product"

}

]

}

我的问题标题“动态键”可能是错误的,但目前我不知道该问题的最佳名称是什么。

任何帮助将不胜感激!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值