0

i have the following json format and trying to filter it using jq. My requirement is to print the "read-transactions" value. I. tried the following but didnt succeed.

validator-info --json | jq .Node_info.Metrics[].read-transactions

Expected output is 0.1233

Any idea what I'm missing here?

{
Node_info": {
    "Metrics": {
      "Delta": 0.12,
      "Lambda": 2410,
      "Omega": 220,
      "average-per-second": {
        "read-transactions": 0.1233,
        "write-transactions": 0.122334
      },
      }
      }
}
user324534
  • 71
  • 1
  • 8

2 Answers2

0

The following should work. This is as per this answer https://stackoverflow.com/a/37344498/1109657

validator-info --json | jq '.Node_info.Metrics."average-per-second"."read-transactions"'
Hariom Balhara
  • 832
  • 8
  • 19
0

Json filter not working on array while using jq

There are no arrays in your JSON, only objects


Since there are some -'s in your path, you'll need to pass the key as string like so:

jq '.Node_info.Metrics."average-per-second"."read-transactions"'

This will output (after making the JSON valid):

0.1233

JqPlay Demo

0stone0
  • 34,288
  • 4
  • 39
  • 64