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

Explicitly document that the last one wins with mergedata()

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Done
    • Priority: (None)
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.15.5, 3.18.1, 3.19.0
    • Component/s: Documentation
    • Labels:
      None
    • Story Points:
      0

      Description

      https://groups.google.com/g/help-cfengine/c/Hy5nYYpZZTk

      But what is supposed to happen when the same key, and with potentially different value, appears in both JSON datasets?

      The last one wins:

      Last one wins
      bundle agent __main__
      {
        vars:
      
            "one" data => '{ "thing": "one", "color": "red", "stuff": [ "one", "two" ] }';
            "two" data => '{ "color": "blue", "stuff": [ "three" ] }';
      
        reports:
            "$(with)" with => storejson( mergedata( one, two ) );
      }
      
      R: {
        "color": "blue",
        "stuff": [
          "three"
        ],
        "thing": "one"
      }

        Attachments

          Activity

            People

            • Assignee:
              a10042 Nick Anderson
              Reporter:
              a10042 Nick Anderson
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: