Pooja
Pooja

Reputation: 47

converting array with single value into string value in JOLT

Input json :

{
  "rating": "5",
  "quality": [
    "No"
  ]
}

Jolt Spec :

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "quality": {
        "0": "=toString"
      }
    }
  }
]

Current Output:

{
  "rating" : "5",
  "quality" : [ "No" ]
}

Expected Output :

{
  "rating" : "5",
  "quality" : "No"
}

please guide me with proper solution, how can I get String value as excepted

Upvotes: 0

Views: 349

Answers (1)

Jagadesh
Jagadesh

Reputation: 2116

If you need only the first object of the quality array, then use "0": "quality", or if it should be generic then use "*": "quality".

But when you use the "*": "quality", if the input json has more than one value in the quality array, then output also, will be having quality as array.

[
  {
    "operation": "shift",
    "spec": {
      "rating": "rating",
      "quality": {
        "*": "&1"
      }
    }
  }
]

Upvotes: 1

Related Questions