문제

I am trying to get the difficulty value out of a JSON structure using jq on the linux command line:

./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:

{
  "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:

./jq '.result.difficulty' status.txt

It yields:

28.20775972
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top