我试图在linux命令行上使用jq从JSON结构中获取难度值:
./jq '{result: .difficulty}' status.txt
(JSON保存在一个名为status.txt的文件中 - 如下所示)但是我可以继续尝试:
{
"result": null
}
归来,有人能告诉我我做错了吗?
{
"result":{
"version":1030000,
"protocolversion":60001,
"walletversion":60000,
"balance":2600.00020000,
"blocks":16042,
"connections":6,
"proxy":"",
"difficulty":28.20775972,
"testnet":false,
"keypoololdest":1382340615,
"keypoolsize":94,
"paytxfee":0.00000000,
"mininput":0.00010000,
"unlocked_until":0,
"errors":""
},
"error":null,
"id":"curltest"
}
答案 0 :(得分:1)
尝试访问result
对象,并在其中提取difficulty
值:
./jq '.result.difficulty' status.txt
它产生:
28.20775972