Convert Integer to String in json, Nifi

Viewed 331

I have the following input json:

{
  "a": "value1",
  "b": [
    {
      "X": 1234
    },
    {
      "X": 4567
    }

    ]
}

I want the integer values to be converted to a string. Basically add double quotes to the integer. Desired output is:

{
  "a": "value1",
  "b": [
    {
      "X": "1234"   // want to add double quotes
    },
    {
      "X": "4567"   // want to add double quotes
    }

    ]
}

How do I achieve this? Thanks in advance.

1 Answers

You can use modify-overwrite-beta transformation spec with toString function embedded such as

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "b": {
        "*": {
          "X": "=toString"
        }
      }
    }
  }
]
Related