2

I have a json string e.g..

 { "value": "{\"userSuspended\":false}" }

What would be the correct Jolt spec to map 'userSuspended' to 'state'?

3
  • 1
    Well, actually you don't have a JSON string. This is not valid JSON syntax. Commented Aug 11, 2020 at 12:06
  • You should edit the question, instead of providing corrections in comments. Commented Aug 11, 2020 at 13:20
  • Apologies - updated. Commented Aug 11, 2020 at 14:39

2 Answers 2

1

It needed two transforms and a Javaclass to map the key/value:

  1. Shift "Value":"Value"
  2. Map the keys 'userSuspended' and 'false' through a javaclass to key/value pairs
  3. Shift the output to "userSuspended":"State"
Sign up to request clarification or add additional context in comments.

Comments

0

One way of doing it is to split the value and save what you wanted to state.

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "stateArray": "=split('\"',@(1,value))"
    }
  },
  {
    "operation": "shift",
    "spec": {
      "stateArray": {
        "1": "state"
      }
    }
  }
]

1 Comment

Thanks, apologies I wasn't very clear - not exactly what I was intending since I wanted the value "false" to be mapped to state.

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.