I am trying to get the value based on the "contains" value of another key in the same object
I have already tried a code and it works and outputs the result that I want, but some objects in the JSON do not have this key as such I get:
jq: error (at <stdin>:1): null (null) and string ("BBC") cannot have their containment checked
or the reason for this error are the arrays in other keys, I am not sure
Using:
jq '.entries[] | select(.icon | contains("BBC")) | .uuid'
I want the UUID of the found result with no errors and store it as a variable in shell
"174501xxxxxxxxxxxxxe6342a03"
Input file that is piped
{
"entries":[
{
"uuid":"174501xxxxxxxxxxxxxe6342a03",
"enabled":true,
"autoname":true,
"name":"BBC",
"number":0,
"icon":"file:///logos/BBC.png",
"icon_public_url":"imagecache/1097",
"epgauto":true,
"epggrab":[ ],
"dvr_pre_time":0,
"dvr_pst_time":0,
"epg_running":-1,
"services":[ ],
"tags":[ ],
"bouquet":""
},
{
"uuid":"174501xxxxxxxxxxxxxe6342a04",
"enabled":true,
"autoname":true,
"name":"ABC",
"number":0,
"icon_public_url":"imagecache/1098",
"epgauto":true,
"epggrab":[ ],
"dvr_pre_time":0,
"dvr_pst_time":0,
"epg_running":-1,
"services":[ ],
"tags":[ ],
"bouquet":""
}...