SimpleJSON

Description
SimpleJSON is an easy to use JSON parser and builder. It uses strong typed classes for the different JSONTypes. The parser / builder does not distinguish between different value types. Number, boolean and null will be treated like strings. This might cause problems when you need to build a JSON string that requires the actual types.

In short: The parser conforms to rfc4627, the generator does not.

Usage
To use SimpleJSON in Unity you just have to copy the SimpleJSON.cs file into your projects "plugins" folder inside your assets folder.

If you want to use the compression feature when it comes to saving and loading you have to download the SharpZipLib assembly and place it next to the SimpleJSON.cs file. In addition you have to uncomment the define at the top of the SimpleJSON.cs file.

For language specific usage see below.

CSharp
Like most assemblies SimpleJSON is contained in it's own namespace to avoid name collisions.

To use SimpleJSON in C# you have to add this line at the top of your script:

UnityScript (Unity's Javascript)
To use SimpleJSON in UnityScript you have to add this line at the top of your script:

For UnityScript it's vital to place the SimpleJSON.cs (and SharpZipLib if needed) into a higher compilation group than the UnityScript file that should use it. The usual place is the Plugins folder which should work in most cases.

Examples (C# / UnityScript)
This is the JSON string which will be used in this example:

Download
Here's the whole thing packed as unityPackage and as seperate files including example / test scripts

[[Media:SimpleJSON.zip]]