Search code examples
jsonapache-nifijolt

Nifi Jolt transformation string to json array


Hi I have following Json input but as you can see "sites" is coming as string but it is actually array of strings which is escaped with \

'''
{ "name":"test", "Id" : "123", "sites": "["BR","DM","LM","MC","WK","ZZ"]" } '''

What I need to transform above using Nifi is as follow

'''
{ "name":"test", "Id" : "123", "sites": ["BR","DM","LM","MC","WK","ZZ"] } ''' how we can do this?


Solution

  • You can use two ReplaceText processors, like here: enter image description here enter image description here

    The first one will replace text "[ with [ while the second one will replace ]" with ]