portal entry

select a category, or use search below
(searches all categories and all time range)
Title:

Converting XML to JSON using xmlTransform()

| View in Portal
December 22, 2018 07:33:32 PM GMT
2 Comments
<p>I know very little about XML other than it’s a pain in the !@#$% to parse, search, and use.  I’m much more familiar with JSON and using ColdFusion structures and arrays.  That being said, I’m working on a project that requires that I pull a data feed of a big, ugly XML document that’s complex and cumbersome to utilize.  The XML is coming from TransUnion (one of the “big three” credit companies in the United States) and it’s a representation […]</p>
<p>The post <a rel="nofollow" href="https://coldfusion.adobe.com/2018/12/converting-xml-json-using-xmltransform/">Converting XML to JSON using xmlTransform()</a> appeared first on <a rel="nofollow" href="https://coldfusion.adobe.com">ColdFusion</a>.</p>
Labels: ColdFusion, Showcase, Training, showcase, training

Comments:

I received the exact same results using 1 line of Java using built-in JSON-Java w/toJSONObject().  I wasn't required to provide XSL file and the performance was consistently faster (0-3ms versus 119-910ms) Here's a link so you can try it out. (Paste your XML in to see the result.) <a href="https://www.trycf.com/gist/00bb362672f772fab56d26f3e01ad3fa/acf11" rel="nofollow">https://www.trycf.com/gist/00bb362672f772fab56d26f3e01ad3fa/acf11</a> <CFSET JSONText = createObject("java","org.json.XML").toJSONObject(XMLText)> <CFSET JSONObject = DeserializeJSON(JSONText)> My short blog entry regarding this is located here: <a href="https://gamesover2600.tumblr.com/post/180776378949/convert-xml-to-json-in-1-line-of-code-using" rel="nofollow">https://gamesover2600.tumblr.com/post/180776378949/convert-xml-to-json-in-1-line-of-code-using</a> NOTE: If you want to retain numeric data types,  you’ll need to use JavaLoader and use a newer version of JSON-Java that supports a secondary “true” argument. This will safely convert number values to text strings instead of converting to scientific notation or rounding.
Comment by James Moberg
1525 | December 26, 2018 02:41:41 PM GMT
Applause needs to go out for that one.
Comment by James Mohler
1519 | December 26, 2018 06:00:49 PM GMT