Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to convert XML to JSON with new JSON structure in Nifi?

How to convert XML to JSON with new JSON structure in Nifi?

Contributor

I get different XMLs from web services. I want to convert this XML to Json, but structure must be changed.

For example, I have XML structure like this;

<root>
    <A attr="attr1">VAL</A>
    <B attr="attr2">VAL</B>
</root>

And result of JSON that I want;;

"root": {
    "Items": [
        {
            "tag_name": "A",
            "attr": "attr1",
            "value": "VAL"
        },
        {
            "tag_name": "B",
            "attr": "attr2",
            "value": "VAL"
        }
    ]
 }

How can I do this in Nifi? ConvertRecord etc.. Also, how should read and write schema be for this if record based processors may be used?