Json 使用GET时筛选结果

Json 使用GET时筛选结果,json,bash,Json,Bash,执行此命令时,我只希望获得一个参数: curl -X GET http://${HUE}/api/${API}/lights/1 我只需要显示true/false,在该参数{“状态”:{“开”: 如何修改GET以仅显示此结果而不是实际结果 {"state":{"on":true,"bri":90,"alert":"select","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinst

执行此命令时,我只希望获得一个参数:

curl -X GET http://${HUE}/api/${API}/lights/1
我只需要显示true/false,在该参数{“状态”:{“开”:

如何修改GET以仅显示此结果而不是实际结果

{"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",...

如果这是一个有效的json,并且您可以访问
jq
实用程序,您可以:

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

这将根据值输出
true
false

是否要使用类似的命令不可能?curl-X GET-H“Content type:application/json”-d'{“state”:“on”}http://${HUE}/api/${api}/lights/1