On Wed, 2020-08-12 at 14:20 -0500, Michael Jones wrote: > 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. > > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > > https://lists.openwrt.org/mailman/listinfo/openwrt-devel > >
Try jsonfilter -e '@["ipv4-address"]' to return the array, and jsonfilter -e '@["ipv4-address"][0].address' to return the first address of the array ... hopefully this works for you (untested). regards dirk
signature.asc
Description: This is a digitally signed message part
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel