<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Apache Nifi - JSON to XML or XML Translation in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222238#M184110</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/18075/akp4tibco.html" nodeid="18075"&gt;@Anil Puvvada&lt;/A&gt; Could you show the whole solution pls, im pretty new in nifi, and I need this json to xml tranformation too. I dont really understood what I have to setup in execute string now. thanks&lt;/P&gt;</description>
    <pubDate>Sat, 20 Jan 2018 15:45:46 GMT</pubDate>
    <dc:creator>jiayu_g3turbo</dc:creator>
    <dc:date>2018-01-20T15:45:46Z</dc:date>
    <item>
      <title>Apache Nifi - JSON to XML or XML Translation</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222230#M184102</link>
      <description>&lt;P&gt;I am looking for a Processor that can convert a JSON to an XML or Translate an XML&lt;/P&gt;&lt;P&gt;The main requirement is to replace the value of certain XML Elements in a XML or build an XML from a DB Query output.&lt;/P&gt;&lt;P&gt;Would also like to know how to insert XML data to DB Table like JSON to SQL&lt;/P&gt;&lt;P&gt;Appreciate any help&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 11:34:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222230#M184102</guid>
      <dc:creator>akp4tibco</dc:creator>
      <dc:date>2022-09-16T11:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi - JSON to XML or XML Translation</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222231#M184103</link>
      <description>&lt;P&gt;Don't know of a processor that directly converts JSON to XML. One option would be to use ExecuteScript with a Groovy script that did the conversion. It looks like there are some examples out there of converting JSON to XML with Groovy:&lt;/P&gt;&lt;P&gt;Example groovyscript:&lt;/P&gt;&lt;PRE&gt;import net.sf.json.JSON
import net.sf.json.JSONSerializer
import net.sf.json.xml.XMLSerializer


String str = '''{ "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": { "GlossEntry": { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": ["GML", "XML"] }, "GlossSee": "markup" } } } } }'''
JSON json = JSONSerializer.toJSON( str )
XMLSerializer xmlSerializer = new XMLSerializer()
xmlSerializer.setTypeHintsCompatibility( false )
String xml = xmlSerializer.write( json )
System.out.println(xml)
&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 May 2017 02:00:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222231#M184103</guid>
      <dc:creator>wbekker</dc:creator>
      <dc:date>2017-05-06T02:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi - JSON to XML or XML Translation</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222232#M184104</link>
      <description>&lt;P&gt;Hi Bekker,&lt;/P&gt;&lt;P&gt;Thanks for the response.&lt;/P&gt;&lt;P&gt;Find below the code I am trying to work on, which is a modification of the code you shared.&lt;/P&gt;&lt;P&gt;I am trying to take the output/flowfile from previous processor (which is a JSON) and trying to convert it to XML flowfile.&lt;/P&gt;&lt;P&gt;Please help identify where I am wrong.&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;import net.sf.json.JSON
import net.sf.json.JSONSerializer
import net.sf.json.xml.XMLSerializer
import java.nio.charset.StandardCharsets
JSON json = JSONSerializer.toJSON( session.get() )
XMLSerializer xmlSerializer = new XMLSerializer()
xmlSerializer.setTypeHintsCompatibility( false )
newFlowFile = session.write(session.create(), {outputStream -&amp;gt;
  outputStream.write(xmlSerializer.write( json ).getBytes(StandardCharsets.UTF_8))
} as OutputStreamCallback)
session.transfer(newFlowFile, REL_SUCCESS)&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;DIV&gt;06:03:44 EDT
ERROR
d89b9512-015b-1000-3b38-ef64f47e9b90
&lt;PRE&gt;ExecuteScript[id=d89b9512-015b-1000-3b38-ef64f47e9b90] ExecuteScript[id=d89b9512-015b-1000-3b38-ef64f47e9b90] failed to process session due to org.apache.nifi.processor.exception.FlowFileHandlingException: StandardFlowFileRecord[uuid=11a424b1-dd59-4199-990a-00afb08f45ba,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1493970997597-1, container=default, section=1], offset=81682, length=5214],offset=0,name=TestTemplate.xml,size=5214] transfer relationship not specified: org.apache.nifi.processor.exception.FlowFileHandlingException: StandardFlowFileRecord[uuid=11a424b1-dd59-4199-990a-00afb08f45ba,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1493970997597-1, container=default, section=1], offset=81682, length=5214],offset=0,name=TestTemplate.xml,size=5214] transfer relationship not specified&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 08 May 2017 17:05:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222232#M184104</guid>
      <dc:creator>akp4tibco</dc:creator>
      <dc:date>2017-05-08T17:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi - JSON to XML or XML Translation</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222233#M184105</link>
      <description>&lt;P&gt;Any idea on how to read the payload / content of flowfile to convert the JSON to XML? Please help.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 13:39:25 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222233#M184105</guid>
      <dc:creator>akp4tibco</dc:creator>
      <dc:date>2017-05-12T13:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi - JSON to XML or XML Translation</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222234#M184106</link>
      <description>&lt;P&gt;Hmm. can't find anything obvious. Best to post a new questions on HCC for this, so it gets the proper attention.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 13:45:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222234#M184106</guid>
      <dc:creator>wbekker</dc:creator>
      <dc:date>2017-05-12T13:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi - JSON to XML or XML Translation</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222235#M184107</link>
      <description>&lt;P&gt;Finally was able to achieve this : &lt;/P&gt;&lt;PRE&gt;flowFile = session.write(flowFile,
        { inputStream, outputStream -&amp;gt;
            def str= IOUtils.toString(inputStream, StandardCharsets.UTF_8)
...
        } as StreamCallback)
&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 May 2017 19:08:32 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222235#M184107</guid>
      <dc:creator>akp4tibco</dc:creator>
      <dc:date>2017-05-12T19:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi - JSON to XML or XML Translation</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222236#M184108</link>
      <description>&lt;P&gt;Excellent! &lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 19:09:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222236#M184108</guid>
      <dc:creator>wbekker</dc:creator>
      <dc:date>2017-05-12T19:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi - JSON to XML or XML Translation</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222237#M184109</link>
      <description>&lt;P&gt;Can you show how you transform the resultant str to xml, in place of the "..." above? Thanks very much.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 21:39:25 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222237#M184109</guid>
      <dc:creator>lt56</dc:creator>
      <dc:date>2017-12-04T21:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi - JSON to XML or XML Translation</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222238#M184110</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/18075/akp4tibco.html" nodeid="18075"&gt;@Anil Puvvada&lt;/A&gt; Could you show the whole solution pls, im pretty new in nifi, and I need this json to xml tranformation too. I dont really understood what I have to setup in execute string now. thanks&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jan 2018 15:45:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222238#M184110</guid>
      <dc:creator>jiayu_g3turbo</dc:creator>
      <dc:date>2018-01-20T15:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi - JSON to XML or XML Translation</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222239#M184111</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/12921/wbekker.html" nodeid="12921" target="_blank"&gt;@Ward Bekker&lt;/A&gt; I am trying the same code but getting error :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="64631-error.jpg" style="width: 705px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15726iD0F8D0D2FF410965/image-size/medium?v=v2&amp;amp;px=400" role="button" title="64631-error.jpg" alt="64631-error.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Code is below one , could you let me know what is wrong, I have added dependency as well.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="64632-deoendency.jpg" style="width: 293px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15727iA8D4938AB2478F9C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="64632-deoendency.jpg" alt="64632-deoendency.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;import net.sf.json.JSON&lt;BR /&gt;import net.sf.json.JSONObject&lt;BR /&gt;import net.sf.json.JSONSerializer&lt;BR /&gt;import net.sf.json.xml.XMLSerializer&lt;BR /&gt;&lt;BR /&gt;String str = '''{ "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": { "GlossEntry": { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": ["GML", "XML"] }, "GlossSee": "markup" } } } } }'''JSON json = JSONSerializer.toJSON( str )&lt;BR /&gt;XMLSerializer xmlSerializer = new XMLSerializer()&lt;BR /&gt;xmlSerializer.setTypeHintsCompatibility( false )&lt;BR /&gt;String xml = xmlSerializer.write( json )&lt;BR /&gt;print(xml)&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Aug 2019 02:09:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-JSON-to-XML-or-XML-Translation/m-p/222239#M184111</guid>
      <dc:creator>gkp_shakeel</dc:creator>
      <dc:date>2019-08-18T02:09:59Z</dc:date>
    </item>
  </channel>
</rss>

