0

I like to get only one parameter when execute this command:

curl -X GET http://${HUE}/api/${API}/lights/1

I need only to show true/false that see in this parameter {"state":{"on":

How can modify the GET to show only this instead the actual result?

{"state":{"on":true,"bri":90,"alert":"select","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2019-01-04T22:37:21"},"type":"Dimmable light","name":"Bombeta menjador 1","modelid":"LWB010","manufacturername":"Philips","productname":"Hue white lamp",...
Guif If
  • 535
  • 2
  • 7
  • 18

1 Answers1

1

If this is a valid json and you have access to jq utility, you can just:

curl .... | jq --compact-output '.state.on'

which will output true or false depending on the value.

KamilCuk
  • 120,984
  • 8
  • 59
  • 111
  • like to use as similar command not's possible? curl -X GET -H "Content-type: application/json" -d '{"state": "on"}' http://${HUE}/api/${API}/lights/1 – Guif If Jan 09 '19 at 23:08