Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Jolt converter keep key

Let say I have an input

{
  "a": 1,
  "b": 2
}

with this spec

[
  {
    "operation": "shift",
    "spec": {
      "a": "wrapper.a",
      "b": "wrapper.b"
    }
  }
]

The output is

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

{
  "wrapper" : {
    "a" : 1,
    "b" : 2
  }
}

But i think maybe there is another shorter way to do the same thing, such as

[
  {
    "operation": "shift",
    "spec": {
      "*": "wrapper.[WHATEVER HERE, NEED HELP FROM YOU GUYS]"
    }
  }
]

Could you guys help to give the solution? Thanks

>Solution :

You just can replace with the operators "*" to match key names of all attributes and "&" to substitute corresponding values for those attributes at the current level(within the current object) such as

[
  {
    "operation": "shift",
    "spec": {
      "*": "wrapper.&"
    }
  }
]

the demo on the site http://jolt-demo.appspot.com/

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading