Convert XML to JSON
Hello everyone!
I have had problem with XML format in Cache Object Script, it was diffucult to parse XML format,
So i decided to convert XML to JSON and parse json easily
So for that i wrote code in java which convert xml to json and build package with maven
Anyone interested can download jar file and see the instructions at the link:
Comments
Interesting.
Can you please add source code for java classes, such as ParseXML.Parse?
Sure.
Class ParseXML.Parse Extends java.lang.Object [ ProcedureBlock ]
{
Method %OnNew(ByRef p0 As %ObjectHandle) As %Status
{
Quit:'$D(p0) $$$OK
Quit ..%Constructor(p0,"ParseXML.Parse",0)
}Method convertXMLtoJSON(ByRef p0 As %ObjectHandle) As %ObjectHandle
{
Quit ..%IR("convertXMLtoJSON",.p0)
}}
Hi Sabit!
Looks interesting!
But I see only jar files in the repo. Could you please submit java source files too?
Hi!
Updated
Using Embedded Python is quite more simple
Method XML2JSON(iXml As %String) [ Language = python ]
{
import xmltodict, json
#; print(iXml)
obj = xmltodict.parse(iXml)
return(json.dumps(obj))
}Just need install
.\irispip.exe install xmltodict