Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2071

mapdata support for jq mode

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Done
    • Priority: (None)
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.9.0
    • Component/s: None
    • Labels:
      None

      Description

      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.

      https://github.com/stedolan/jq/wiki/C-API:-jq-program-invocation
      https://github.com/stedolan/jq/wiki/C-API:-jv
      https://github.com/stedolan/jq/wiki/C-API:-libjq

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10003 Eystein Maloy Stenberg
                Reporter:
                tzz Ted Zlatanov
              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel