0

I have the following JSON object

Input:

{
  "17.39.108.85:80": [],
  "10.204.32.9:443": [
    {
      "status": "DOWN"
    }
  ]
}

and trying to transform it into a list/array as below :

Desired Output:

[
  {
    "17.39.108.85:80": []
  },
  {
    "10.204.32.9:443": [
      {
        "status": "DOWN"
      }
    ]
  }
]

What's the best way to use Jolt.

1 Answer 1

2

You can use this spec:

Currently, your input is correct, but you need to put each key into an array.

You can get each key in the object and send it to an array with [#2].

Note: #2 is the index of each key. for example: 17.39.108.85:80 is 0 and 10.204.32.9:443 is 1.

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "@": "[#2].&"
      }
    }
  }
]
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you mohammadReza and @Barbaros Özhan This worked beautifully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.