Rather than parsing the structure myself, I have decided to go with the XML 
library that converts to JSON for me.


import org.json.JSONObject
import org.json.XML


def xml = 
'<record><property1>Lake<BR/>River<BR/>National_State_Park</property1><property2>A:Value1<BR/>B:Value2<BR/>C:Value3<BR/>D:Value4<BR/>E:Value5</property2></record>'

def textIndent = 2
def xmlJSONObj = XML.toJSONObject(xml)
xmlJSONObj.toString(textIndent)


Thanks,
Keith


________________________________
From: Keith Lim
Sent: Wednesday, June 01, 2016 9:44:11 AM
To: [email protected]
Subject: Re: Which processor to use to cleanly convert xml to json?


Thanks Bryan and Thad for the quick response,


I like these more established libraries.  I will go with the Groovy example.


Thanks,
Keith

________________________________

From: Thad Guidry <[email protected]>
Sent: Wednesday, June 01, 2016 9:35 AM
To: [email protected]
Subject: Re: Which processor to use to cleanly convert xml to json?

You can use the ExecuteScript processor with Groovy to easily slurp XML and 
then build the Json.

http://stackoverflow.com/questions/23374652/xml-to-json-with-groovy-xmlslurper-and-jsonbuilder
[http://cdn.sstatic.net/Sites/stackoverflow/img/[email protected]?v=73d79a89bded&a]<http://stackoverflow.com/questions/23374652/xml-to-json-with-groovy-xmlslurper-and-jsonbuilder>

XML to JSON with Groovy XmlSlurper and JsonBuilder - Stack 
...<http://stackoverflow.com/questions/23374652/xml-to-json-with-groovy-xmlslurper-and-jsonbuilder>
stackoverflow.com
I am trying to take an XML file and convert it into a JSON document using 
Groovy, specifically with XmlSlurper and JsonBuilder. I can do this fairly 
easily if I hard ...




http://funnifi.blogspot.com/2016/02/executescript-explained-split-fields.html

Thad
+ThadGuidry<https://www.google.com/+ThadGuidry>

Reply via email to