我想檢索投票給定一個特定的ID,數據(恭維到)存儲在json中,我在Python中編寫並打算使用js。基於一個嵌套值在Json中檢索值
例如輸入 「Y000062」 應產生 「贊成」
{
"bill": {
"congress": 114,
"type": "hr"
},
"category": "passage",
"votes": {
"Aye": [
{
"display_name": "Abraham",
"id": "A000374",
},
{
"display_name": "Yarmuth",
"id": "Y000062",
}
],
"Nay": [
{
"display_name": "Clyburn",
"id": "C000537",
},
]}}
在終端中的溶液是貓/ccc/114/votes/2015/H384/data.json | egrep'Nay | Not Voting | Present | Yea | Aye | Y000062'| grep -B 1'Y000062'|頭-1 但中繼到python子進程看起來像一個笨重的解決方案。
注意到:以JSON {}是一個對象,[]是一個數組