我有以下格式的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) 我有一个json对象是这样的:
{
Yg7R_: {
fld_invoice: "Yg7R_"
fld_order_id: "5"
fld_orders: {
4: {
fld_oiid: "4"
fld_date: "2014-03-27 00:00:00"
fld_name: "20140327_H5epz2y4OB_IMG_20140326_020341.jpg"
fld_loc: "../orders/oid_5/"
}
}
}
LldP_: {
fld_invoice: "LldP_"
fld_order_id: "7"
fld_orders: {
6: {
fld_oiid: "6"
fld_date: "2014-03-27 00:00:00"
fld_name: "20140327_SovH7Xf3n2_IMG_20140326_020418.jpg"
fld_loc: "../orders/oids_7/"
}
}
}
NYEO: {
fld_invoice: "NYEO"
fld_order_id: "24"
fld_orders: {
27: {
fld_oiid: "27"
fld_date: "2014-03-27 00:00:00"
fld_name: "20140327_duLLsssVWA_IMG_20140326_020341.jpg"
fld_loc: "orders/oid_24/"
}
28: {
fld_oiid: "28"
fld_date: "2014-03-27 00:00:00"
fld_name: "20140327_F8ayA4vWrP_IMG_20140326_020405.jpg"
fld_loc: "orders/oid_24/"
}
29: { …Run Code Online (Sandbox Code Playgroud)