0
votes

I would like to get convert list/array of string to dict/map using Jolt transform. Playground here: https://jolt-demo.appspot.com/#inception

Input json is:

{
  "sites": {
    "urls": [
      "https://google.com/",
      "https://www.netflix.com/",
      "https://www.epicgames.com/"
    ]
  }
}

Output expected:

{
  "sites": [
    {
      "link": {
        "url": "https://google.com/"
      }
    },
    {
      "link": {
        "url": "https://www.netflix.com/"
      }
    },
    {
      "link": {
        "url": "https://www.epicgames.com/"
      }
    }
  ]
}

I tried around other transforms but didn't found example for list of strings to map/dictionary. Here we have fixed key for output as link and url. Any pointer on solution will be helpful. Thank you.

1
Please show us your attempt - Jagadesh
What I tried was pretty useless. Wasn't changing anything in output: - mrtipale

1 Answers

2
votes

Check this spec

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": {
          "*": {
            "@": "sites[].link.url"
          }
        }
      }
    }
  }
]