blog games developers documentation portfolio gallery

More in this category:


Import any JSON string into Unity at runtime. The results are formatted as a hierarchy of good old Hashtables and ArrayLists.

No fancy stuff, no nonsense, just an Importer and a few extensions to the existing C# Hashtable and ArrayList classes. It also doesn't start throwing exceptions the second the XML isn't 100% according to standards.

I said no fancy stuff, but I lied. There are a few extra functions:
- export as XML
- export as JSON
- find node at path
- find node by property value
You can test it all if you run the Demo scene that is included. Or you can run the demo here.

To obtain the SimpleJSON package, go to the Unity Asset Store

To use SimpleJSON in your Unity project, you need to have the files SimpleJsonImporter.cs and SimpleJsonExtensions.cs somewhere in your project folder.

Some code examples:

// import a JSON string
myHashtable = SimpleJsonImporter.Import(jsonString);

// export
string xmlString = myHashtable.XmlString();
string jsonString = myHashtable.JsonString();

// query the hierarchy
selectedNode = myHashtable.GetNodeWithProperty("author", "George Orwell");

More functions for accessing members can be found here and here.

follow us