我試圖從以下JSON數組中獲取項目名稱,品牌名稱和總碳水化合物值,但在訪問「字段」部分中的各個值時遇到問題。任何人有任何指針來檢索這個信息?如何解析兩個JSON數組中的JSON對象?
{
「total_hits」:49127, 「MAX_SCORE」:11.919899, 「點擊」:[{
"_index": "f762ef22-e660-434f-9071-a10ea6691c27",
"_type": "item",
"_id": "513fceb375b8dbbc21000022",
"_score": 11.919899,
"fields": {
"item_id": "513fceb375b8dbbc21000022",
"item_name": "Cheese, cheddar - 1 cup, diced",
"brand_name": "USDA",
"nf_total_carbohydrate": 4.08,
"nf_serving_size_qty": 1,
"nf_serving_size_unit": "serving"
}
},
{
"_index": "f762ef22-e660-434f-9071-a10ea6691c27",
"_type": "item",
"_id": "513fceb375b8dbbc21000021",
"_score": 11.788424,
"fields": {
"item_id": "513fceb375b8dbbc21000021",
"item_name": "Cheese, cheddar - 1 cup, melted",
"brand_name": "USDA",
"nf_total_carbohydrate": 7.54,
"nf_serving_size_qty": 1,
"nf_serving_size_unit": "serving"
}
/*對不起由於某種原因,我不能得到正確的格式,但在「命中」是整個的父突出顯示的代碼段*/
發佈正確格式JSON響應... – rafsanahmad007