AMUK786
AMUK786

Reputation: 31

Json string to Json using Java and Jolt

I have a json string e.g..

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

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

Upvotes: 2

Views: 1258

Answers (2)

AMUK786
AMUK786

Reputation: 31

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"

Upvotes: 1

TSL
TSL

Reputation: 161

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"
      }
    }
  }
]

Upvotes: 0

Related Questions