Affects Version/s: None
Fix Version/s: 3.9.0
jq is a very nice utility for command-line processing of JSON data. Here's a cookbook showing some fun features: https://github.com/stedolan/jq/wiki/Cookbook
And here's the manual: https://stedolan.github.io/jq/manual/
It's well-documented and even has a C API.
According to https://github.com/stedolan/jq/blob/master/COPYING it should be OK to include the source of jq in the @3rdparty@ directory of the core. I'd appreciate it if someone could check on that.
If the source code of jq is in the core, we can use its API in the @mapdata()@ function.
Right now, @mapdata()@ has the modes @json@ (strings are parsed as JSON data) and @none@ (strings are returned without parsing in a slist).
I propose adding a third mode, @jq@, which maps a data container through a jq filter. The filters are extremely powerful and even have their own mini-language, but the key here is that we don't have to invent or maintain this language. We'll just pass a JSON data container to jq and get back something we can use in CFEngine. I think this will benefit CFEngine users in a huge way.
If Eystein and others are OK with this proposal, I think I can write the C code. Let me know what you think, please.