jsonfilter and queries with '-' in them

Michael Jones mike at meshplusplus.com
Wed Aug 12 15:20:49 EDT 2020


Hi List,

I am trying to query netifd via ubus for the list of ipv4 ipaddresses
associated with an interface.

Currently my query looks like

ubus call network.interface.wan status | jsonfilter -e "@.ipv4-address"
Syntax error: Invalid escape sequence
In expression @.ipv4-address
Near here ----------^

However, underscores work just fine.

ubus call network.interface.wan status | jsonfilter -e "@.dns_metric"
0

Is there a specific trick to informing jsonfilter of identifiers with
dashes in them?

I can work around this by returning anything that has an "address"
key. This isn't optimal since it'll give me ipv6 addresses as well,
but I can filter those out with grep.

ubus call network.interface.wan status | jsonfilter -e "@.*[*].address"
10.1.0.1

Or further constrain it by only returning the "address" key of objects
that have a "mask" key
ubus call network.interface.wan status | jsonfilter -e "@.*[@.mask].address"
10.1.0.1

But I'd really like to understand why it's unhappy with the '-' character.



More information about the openwrt-devel mailing list