Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

array response is having escape character

avatar
Explorer

I fetched the data from hbase using fetchHbaseRow and the response is in json format. but the value for the attribute is array of objects and it is having escaped characters in there.


A sample response is posted below:

{"someValues":"[{\"a\":\"6f7f8ffe-4837-4fc1-a5b9-45bc35727b69\",\"b\":\"da_states\",\"doc\":\"unknown\",\"idNew\":\"2846e8e1-5b17-490c-a99e-df1f1e3fa009\",\"status\":\"Approved\",\"scope\":\"Global\",\"dateModified\":\"2019-04-19T11:26:02Z\"}]"}


I need to split the objects in array and because of escape characters I am not able to.

@Matt Burgess



1 ACCEPTED SOLUTION

avatar
Master Guru
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
4 REPLIES 4

avatar
Master Guru
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login

avatar
Explorer

Thanks @Shu.
But this does not solve my problem. It does remove the \ from the json but the response is still not in the json response.

{"someValue":"[{"id":"6f7f8ffe-4837-4fc1-a5b9-45bc35727b69","name":"da_st","doc":"unknown","pnId":"2846e8e1-5b17-490c-a99e-df1f1e3fa009","status":"Approved","scope":"Global","dateModified":"2019-04-19T11:26:02Z"},{"id":"3559741f-76f6-4fb4-b919-6def5e0511fe","name":"Het","doc":"unknown","pnId":"2846e8e1-5b17-490c-a99e-df1f1e3fa009","status":"Approved","scope":"Global","dateModified":"2019-04-19T11:26:00Z"},{"id":"3b66fbda-9a16-48ac-9fd0-122e3826ef80","name":"queue","doc":"unknown","pnId":"2846e8e1-5b17-490c-a99e-df1f1e3fa009","status":"Approved","scope":"Global","dateModified":"2019-04-19T11:26:01Z"}]"}


The response should have been :

{"someValue":[{"id":"6f7f8ffe-4837-4fc1-a5b9-45bc35727b69","name":"da_st","doc":"unknown","pnId":"2846e8e1-5b17-490c-a99e-df1f1e3fa009","status":"Approved","scope":"Global","dateModified":"2019-04-19T11:26:02Z"},{"id":"3559741f-76f6-4fb4-b919-6def5e0511fe","name":"Het","doc":"unknown","pnId":"2846e8e1-5b17-490c-a99e-df1f1e3fa009","status":"Approved","scope":"Global","dateModified":"2019-04-19T11:26:00Z"},{"id":"3b66fbda-9a16-48ac-9fd0-122e3826ef80","name":"queue","doc":"unknown","pnId":"2846e8e1-5b17-490c-a99e-df1f1e3fa009","status":"Approved","scope":"Global","dateModified":"2019-04-19T11:26:01Z"}]}


The quotes should not be present before and after the array brackets([]).


avatar
Master Guru

@Raj Negi

Use nifi expression language to replace function to replace "[ and ]" with [ and ]


${'$1':unescapeJson():replace('"[','['):replace(']"',']')} 

avatar
Explorer

Thanks @Shu

I had done the same in my case with some minor modifications.