[英]Parsing json using jq
I am trying to get the difficulty value out of a JSON structure using jq on the linux command line: 我正在尝试在linux命令行上使用jq从JSON结构中获取难度值:
./jq '{result: .difficulty}' status.txt
(The JSON is held in a file called status.txt - shown below) But try as I might I keep getting: (JSON保存在一个名为status.txt的文件中-如下所示),但请尝试一下,我可能会不断得到:
{
"result": null
}
Returned, can someone tell me what I am doing wrong? 返回时,有人可以告诉我我做错了吗?
{
"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"
}
Try to access to result
object and inside it extract the difficulty
value: 尝试访问result
对象并在其中提取difficulty
值:
./jq '.result.difficulty' status.txt
It yields: 它产生:
28.20775972
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.