XML to JSON

Hello…

is there any possibility to convert XML to JSON?

I have servoy developer 6.1

thanks

Hi,

Yes, in general it’s possible. It all depends on what you want to do actually.

i want to convert the XML object structured with childs into a json format…

I think what Robert is trying to say is, Yes this is possible to do, but there is no one correct way of doing it, and there is no (that I know of) generic way of doing it bundled with Servoy.

Servoy, and related plugins, provide several ways to both read structured XML and ways to output JSON. Between these two you should be able to make informed decisions based on what your specific XML looks like and what you desire the end JSON to look like and fairly easily create a specific mapping to suit your current needs.

Have a look here: http://www.thomasfrank.se/xml_to_json.html

Thomas Frank wrote a JavaScript program to convert XML to JSON. You can try it out on his webpage by pasting your XML in the testpane and see if it converts correctly. If it does you can download the script and use it.

thanks! i am new with servoy and i suppose that if i download directly this script it wouldn’t work so i have to convert it to servoy istruction is that correct or there is a possibility to use it directly?

Try this little plugin.

http://www.adinf.com.es/descargas/xml2json.rar

Best regards.

DEK4:
thanks! i am new with servoy and i suppose that if i download directly this script it wouldn’t work so i have to convert it to servoy istruction is that correct or there is a possibility to use it directly?

Yes, it works, just copy and paste it in your globals file. There will be a few warnings, but no errors.

I made one small change:

var xml2json={

I put ‘var’ in front of xml2json.