Ignition 8.0.16
I use jsonGet expression with a Document Tag.
I search a key
Broadcom NetXtreme Gigabit Ethernet
with:
jsonGet(jsonGet(toString({[.]../_intern/IF_TABLE}),"Broadcom NetXtreme Gigabit Ethernet"),"_1_3_6_1_2_1_2_2_1_8")
Return is Ok
and another key
Broadcom NetXtreme Gigabit Ethernet #2
with:
jsonGet(jsonGet(toString({[.]../_intern/IF_TABLE}),"Broadcom NetXtreme Gigabit Ethernet #2"),"_1_3_6_1_2_1_2_2_1_8")
Return is Not Ok
Is there any characters invalid for key used with jsonGet expression ?
The ‘#’ in there prevents it from being treated like a path, so you have to use the clunky square bracket syntax instead:
jsonGet("...some JSON...", "['Broadcom NetXtreme Gigabit Ethernet #2']")
Any time you would have a path like this:
jsonGet("...some JSON...", "foo.bar")
you can also do this:
jsonGet("...some JSON...", "['foo']['bar']")
where the former syntax only allows what would be valid JS identifiers (though it also accepts spaces in them).
2 Likes
Thanks @Kevin.Herron! This just saved me. This would be really helpful to add the user manual. Cheers!