title: jq - using map function to preserve the currently sorted order of properties
body: <p>I have the following JSON named as <em>my.json</em>.</p>
  <pre><code>[
    {
      &quot;action&quot;: &quot;copy&quot;,
      &quot;artifact_location&quot;: &quot;one foo one&quot;
    },
    {
      &quot;action&quot;: &quot;copy&quot;,
      &quot;artifact_location&quot;: &quot;one bar one&quot;
    },
    {
      &quot;action&quot;: &quot;remove&quot;,
      &quot;artifact_location&quot;: &quot;two foo two&quot;
    }
  ]
  </code></pre>
  <p>I'm trying to understand the usage of the <em>map function</em> in <em><strong>jq version 1.3</strong></em>.</p>
  <p>Later, I intend the use this logic (i.e. <em>map function</em>) for a complex jq filter to preserve the currently sorted order of properties in each object as <em>--sort-keys</em> option is <strong>not</strong> available in <em><strong>jq version 1.3</strong></em>.</p>
  <p>My goal is to output the content of the <em>my.json</em> file as it as after using the map function.</p>
  <p>So far, I have come up with the following <em>jq</em> command based on the answers <a href="https://stackoverflow.com/a/42324565/5729556">[1]</a> and <a href="https://stackoverflow.com/a/24315502/5729556">[2]</a>.</p>
  <pre><code>jq -r 'map(to_entries | map({(.key): .value}))' my.json
  </code></pre>
  <p>Which gives me the following output.</p>
  <pre><code>[
    [
      {
        &quot;action&quot;: &quot;copy&quot;
      },
      {
        &quot;artifact_location&quot;: &quot;one foo one&quot;
      }
    ],
    [
      {
        &quot;action&quot;: &quot;copy&quot;
      },
      {
        &quot;artifact_location&quot;: &quot;one bar one&quot;
      }
    ],
    [
      {
        &quot;action&quot;: &quot;remove&quot;
      },
      {
        &quot;artifact_location&quot;: &quot;two foo two&quot;
      }
    ]
  ]
  </code></pre>
  <p>If I combine the <em><strong>add</strong></em> function as follows.</p>
  <pre><code>jq -r 'map(to_entries | map({(.key): .value}) | add )' my.json
  </code></pre>
  <p>It <strong>changes the previously sorted order</strong> of properties similar to the output below.</p>
  <pre><code>[
    {
      &quot;artifact_location&quot;: &quot;one foo one&quot;,
      &quot;action&quot;: &quot;copy&quot;
    },
    {
      &quot;artifact_location&quot;: &quot;one bar one&quot;,
      &quot;action&quot;: &quot;copy&quot;
    },
    {
      &quot;artifact_location&quot;: &quot;two foo two&quot;,
      &quot;action&quot;: &quot;remove&quot;
    }
  ]
  </code></pre>
  <p>What am I missing here?</p>