Author Topic: XML/JSON Parser  (Read 1240 times)

Is there a Torquescript XML parser out there, or do I need to make one?
« Last Edit: June 14, 2015, 05:53:14 PM by Greek2me »

pretty sure there was one in RTB though idk how extensive it was

According to this post, one shipped with TGE: http://www.garagegames.com/community/blogs/view/18107
I'm trying to track it down. Thanks for the RTB extension - I will check there.

I also found one by Mr. Doom over at ScatteredSpace, but he has a weird license on all of his scripts.

oh this is the xml.cs that came with TGB

https://dl.dropboxusercontent.com/u/11058668/asd/xml.cs


appears to use a class that i doubt exists/i have never before seen in this version of torque tho so gg and i don't guess source files would help lol
« Last Edit: June 13, 2015, 07:34:06 PM by otto-san »



Can confirm that the class used in xml.cs and in the example in the website you gave doesn't exist in blockland.

Out of curiosity, why use xml when there are much leaner alternatives?

Out of curiosity, why use xml when there are much leaner alternatives?

Web development isn't my thing. Can you give an example?

XML is widely used and there are libraries for it in many languages. I was planning on transitioning Support_Updater to XML-based repositories.

Web development isn't my thing. Can you give an example?

XML is widely used and there are libraries for it in many languages. I was planning on transitioning Support_Updater to XML-based repositories.
JSON is "leaner" and has just as much support, including a torquescript parser.
But if you're connecting to someone else's web service, you (usually) have to use whatever format they use
« Last Edit: June 13, 2015, 07:53:17 PM by Headcrab Zombie »

But if you're connecting to someone else's web service, you (usually) have to use whatever format they use

I'm writing the specs for the repositories, so I can specify any plaintext format I want. I don't know much about JSON so I'll start doing some research and comparing it with things like XML.

Is there anything I should know going into this about either one (XML, JSON) or any limitations of either?

You'll learn that it's much easier to read and it probably parses faster, not that it matters a whole lot, along with other miscellaneous advantages.

I typically see XML used to store stuff in a file, whereas JSON I see more often over network applications to save bandwidth because of its slightly lower character use
There's no real reason you have to use one over the other, that's just what I see more.
I'd just use whichever one has more support (JSON in this case)


The biggest disadvantage i see to JSON is it doesn't have attributes like XML does

The format is basically {"key":"value","key":"value"}
You can have arrays: {"key":["one","two","three"]}
and objects {"key": { "key":"value","key":"value"}}
and all the further nesting you'd expect like objects in objects and arrays of objects and etc

For a more complex example, here is your complex repository example in JSON format
« Last Edit: June 13, 2015, 09:51:17 PM by Headcrab Zombie »

The repository example was very useful! Port did a good job with Jettison, so I'll likely be using that.

Thank you all!

« Last Edit: June 14, 2015, 02:36:12 PM by Greek2me »

If you ask me the repository version of Jettison is sort of bad. I have a few better rewrites lying around in certain places but no distinct newest version right now.

Let me know if you find a better version I should be using.

Also, I found another JSON parser here.