From Unify Community Wiki
Revision as of 16:49, 17 December 2012 by Ppeterson (Talk | contribs)

Jump to: navigation, search



Looking for a C# solution? Try JSONObject.


This software has known bugs. It does not seem to build for iOS and has not been tested on Unity 4. If you have problems with this script, please report them to the author and use JSONObject until the issue is fixed.

What is it?

It's a JSON parser written in UnityScript ("UnityJS"). A project I was working on needed one, and the only good existing one at the time of this writing is JSONObject, which (a) is written in C# (b) at the time did not take into account escaped characters within strings (it does now). So I ported Douglas Crockford's json_parse() function published in his book, JavaScript: The Good Parts.

Wait, you had to port it? Why couldn't you just copy and paste, if it was in JavaScript?

It was in JavaScript, which is not the same thing as the language everyone on this forum pretends is JavaScript. That language is actually UnityScript. Real JavaScript sucks less.

Why not just use eval()?

The problem with eval() as far as Unity goes is that it just translates your UnityScript into Boo then compiles it to the Mono CLR, as it does with the rest of your code before it can get run. As a result, eval() is really, really slow. So it's best to just parse it at runtime without having to compile.

Where's the code?

Download from GitHub.

Who do I contact for help / questions?

Philip Peterson.

Personal tools