Hi,
> [...]
> What I want to do is return a JSON string with this representation:
> [
> { "interface" : "lan", "uptime" : 11111 },
> ...
> ]
>
> E.g., I want to filter the json not down to a single value, but to a
> collection of key-value pairs by excluding items that don't match.that is not directly possible. You can use the shell export mode together with the field separator to build a list of tuples safe for processing, printf the intermediate fields and finally use the array mode to build a proper list: -- 8< -- eval $(ubus call network.interface dump | \ jsonfilter -F ': ' -e '[email protected][@.up=true]["interface","uptime"]') for tuple in $tuples; do printf '{ "%s": %d }\n' "${tuple%:*}" "${tuple#*:}" done | jsonfilter -a -e @ -- >8 -- Will result in something like the output below: [ { "lan": 4409874 }, { "loopback": 4409873 }, { "modem": 803939 }, { "wan": 4040845 }, { "wan6": 2681477 } ] Returning subsets of objects is not directly supported unfortunately but I'll think about how to add something like this if I find the time. ~ Jo
signature.asc
Description: OpenPGP digital signature
_______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/mailman/listinfo/openwrt-devel
