Home > Software engineering >  How to insert on top in JQ?
How to insert on top in JQ?

Time:10-09

This can let me insert a key/value pair to a json, but how do I insert the "k0": 0 before the "k1": 1?

enter image description here

I would like the result to be:

    {
        "k0": 0,
        "k1": 1
    }

Thank you!

CodePudding user response:

One option is creating an object with only k0-0 pair and adding the input to it like so:

{k0: 0}   .
  • Related