Created 03-13-2018 01:10 PM
I have input NIFI flow content:
{"page_id":"page_bb51c576-a885-482f-bf19-648f0b654745","group_id":"MFGRPPA000054","provider":"{\"addresses\":\"[\\\"1405 Shady Avenue, Pittsburgh, PA\\\"]\",\"education\":\"[{\\\"name\\\":\\\"TEXAS A&M UNIVERSITY COLLEGE OF MEDICINE\\\",\\\"graduation_date\\\":\\\"\\\"}]\",\"last_name\":\"Oandasan\",\"affiliations\":\"\",\"middle_name\":\"\",\"suffix\":\"\",\"certifications\":\"[\\\"ADULT PSYCHIATRY, CHILD & ADOLESCENT PSYCHIATRY – AMERICAN BOARD OF PSYCHIATRY AND NEUROLOGY\\\"]\",\"degrees\":\"[\\\"MD\\\"]\",\"internships\":\"[]\",\"fellowships\":\"[]\",\"phone_numbers\":\"[\\\"4124202400\\\",\\\"41242024001405\\\",\\\"8007320999\\\"]\",\"specialties\":\"[\\\"CHILD & ADOLESCENT PSYCHIATRY\\\"]\",\"residencies\":\"[\\\"GENERAL PSYCHIATRY, GEORGETOWN UNIVERSITY\\\"]\",\"name\":\"Aileen Oandasan\",\"state\":\"PA\",\"first_name\":\"Aileen\"}","org_name":"CHILDREN'S INSTITUTE OF PITTSBURGH, THE","scrape_id":"scrape_42d77b5d-19c1-4760-94bc-1fdf4c3b1d79"}
I need to replace the content with following
]\" => ]
\"[ => [
\ => empty
Can you please help me how to achieve this in NIFI?
Thanks,
Bob
Created on 03-13-2018 01:49 PM - edited 08-18-2019 02:39 AM
You can achieve that by using three successive replace text processors with the below
Configs:-
Replacetext1:-
Search Value
\]\"
Replacement Value
]
Maximum Buffer Size
1 MB
Replacement Strategy
Regex Replace
Evaluation Mode
Entire Text
Replacetext2:-
Search Value
\"\[
Replacement Value
[
Replacement Strategy
Regex Replace
Evaluation Mode
Entire text
ReplaceText3:-
in this processor we are trying to replace \(backslash) with empty string.
Search Value
\
Replacement Value
Empty string set
Replacement Strategy
Regex Replace
Evaluation Mode
Entire text
The output from the last replacetext processor would be
{ "page_id": "page_bb51c576-a885-482f-bf19-648f0b654745", "group_id": "MFGRPPA000054", "provider": "{"addresses":["1405 Shady Avenue, Pittsburgh, PA"],"education":[{"name":"TEXAS A&M UNIVERSITY COLLEGE OF MEDICINE","graduation_date":""}],"last_name":"Oandasan","affiliations":"","middle_name":"","suffix":"","certifications":["ADULT PSYCHIATRY, CHILD & ADOLESCENT PSYCHIATRY – AMERICAN BOARD OF PSYCHIATRY AND NEUROLOGY"],"degrees":["MD"],"internships":[],"fellowships":[],"phone_numbers":["4124202400","41242024001405","8007320999"],"specialties":["CHILD & ADOLESCENT PSYCHIATRY"],"residencies":["GENERAL PSYCHIATRY, GEORGETOWN UNIVERSITY"],"name":"Aileen Oandasan","state":"PA","first_name":"Aileen"}", "org_name": "CHILDREN'S INSTITUTE OF PITTSBURGH, THE", "scrape_id": "scrape_42d77b5d-19c1-4760-94bc-1fdf4c3b1d79" }
Flow:-
If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.
Created 03-13-2018 02:43 PM
I guess you need to drop these expressions one at a time. Using multiple ReplaceText processors. For example for the first pattern, you can use the replace text as follows.
Similarly, you can replace your patterns in the "Search Value" text box with following expressions.
(?s)(\\\"\[) (?s)(\\)
Hope that helps!