I am new to this topic, but I hope you can help me. I can't figure out a correct JSON expression for solving my problem.
Given JSON structure (coming from zigbee2mqtt):
{
"message" : "announce",
"meta" : {
"friendly_name" : "Lamp1"
},
"type" : "device_announced"
}
What I am trying:
if $.type == 'device_announced' then return the friendly_name
which in this case is
Lamp1
If I understand correctly, you are looking for an expression like this:
So, we are filtering the root collection on
type
s equal to the search string, and then drill down to the friendly_name. You can test this online here.Note: Some implementations require you to wrap your JSON in an array
[ ]
to allow this kind of filtering.