Skip to content

Latest commit

 

History

History
57 lines (46 loc) · 787 Bytes

jq-json-tool.md

File metadata and controls

57 lines (46 loc) · 787 Bytes

jq json tool

replace data

  • appsettings.json example
{
  "Logging": {
    "LogLevel": {
      "Default": "Information"
    }
  }  
}
  • cat appsettings.json | jq '.Logging.LogLevel.Default |= "Debug"'
{
  "Logging": {
    "LogLevel": {
      "Default": "Debug"
    }
  },
  "AllowedHosts": "*"
}

extract data example 1

[{"name":"bathroom","value":18.250000},{"name":"lab","value":17.187500},{"name":"external","value":0.000000},{"name":"bedroom","value":14.937500},{"name":"livingroom","value":17.500000}]

query:

cat data | jq -r '.[] | select(.name=="lab")'

result:

{
  "name": "lab",
  "value": 17.1875
}

query:

cat data | jq -r '.[] | select(.name=="lab") | .value'

result:

17.1875