I have a JSON that starts like this (I have edited the end of the file to close the opening bracket to make it a valid file):
{
"YRPLBn9VEgpB4pc": {
"name": "Bright",
"lights": [
"8"
],
"owner": "VHB3Xij-S9AfghoMDL6ccgCEOOE00Fs43nzBbNgR",
"recycle": false,
"locked": false,
"appdata": {
"version": 1,
"data": "7prbY_r03_d05"
},
"picture": "",
"lastupdated": "2018-07-24T12:51:03",
"version": 2
},
"oRvYDYW6dMmGoUw": {
"name": "Dimmed",
"lights": [
"8"
],
"owner": "VHB3Xij-S9AfghoMDL6ccgCEOOE00Fs43nzBbNgR",
"recycle": false,
"locked": false,
"appdata": {
"version": 1,
"data": "jBjTp_r03_d06"
},
"picture": "",
"lastupdated": "2018-07-24T12:51:03",
"version": 2
}
}
It is returned by the Philips Hue Clip api in response to a query asking for all scenes saved on the bridge.
I want to iterate over this (ideally in bash, but I am open to suggestions) so that I can get the items "YRPLBn9VEgpB4pc", "oRvYDYW6dMmGoUw" etc. I know how I would get the values from key pairs*, but I don't really understand what these items are - object ids, perhaps?
*get value from "name" using jq:
for row in $(echo "${sample}" | jq -r '.[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1};
};
echo $(_jq '.name');
done