- Home /
Can anyone recommend a json parser good for using with a web api?
I am currently using SimpleJSON and I'm trying to send the data back and forth to a webapi. Whenever I try to add nodes or send/recieve data to the API, i end up, regardless of the escape sequences with a bunch of horribly mangled data.
My big problem is, the "tostring" method that SimpleJSON impelements. It adds a lot of escaped characters like \r\n and \". I end up having to manually remove a lot of it, and don't get me started on what happens if you call WWW.EscapeURL on the string before I send it to the api.
So, rather than go on and on about how bad simplejson is, anyone have a better solution?
Thanks so much!
Is it bad or are you using it wrong? You are one of the first to say it is inappropriate.
You may also just develop your own that does just what you need. This is what I do when I need a parser since those you find online are meant to be used anywhere in any situation and may not do as good as cut-to-fit one.
Hi, thanks for the response.
fafase, I don't think I'm using it wrong.
If I request a clean json object from the webapi, and parse it with simple JSON it works fine.
As a var, I can modify nodes, add nodes, and remove nodes just fine. However when I want to update the value of that node via web api, it will break.
I believe the core problem is that the method .tostring() which I have to call to construct the url for the web api injects carriage returns and marks up quotation marks.
Well, you're not using it wrong ;) The problem is that i wrote it mainly as parser and not really as a full JSON framework. That's why every "value" is treated like a string value (so true, false and numbers are just treated like strings since i don't analyse or store that information at all)
I have this for quite a long time on my "todo" list. I want to implement a seperate class for the different literal values which should serialize properly. However i can't find the time, sorry ;)
Hey thanks for the response Bunny83. Well, its good to know its not me. And yes, I've gotten used to the quirks of every value being a string and I just run int parse or tostring when I need to.
I am not sure if it will be easier to extend your tostring method or to find another solution. I suppose I will see what I come up with.
Thanks again for writing it, up until this point its been great.