TotalJSON


Introduction

Total JSON is fast, light-weight JSON package. Completely stand-alone, no depencies, nothing but C#, works on any platform.

Does all the basic things. Create and modify JSON, parse strings to JSON and turn JSON objects to strings (compact or pretty), serialize objects to JSON and JSON back to objects.

But made with Unity in mind:

Safe:

And lot more:


Extra features

Debugging in Unity Editor

For easy debugging, you can follow content of JSON objects in Unity Editor when application is running.

In your code, you can add any JSON object to debug by saying
myJsonObject.DebugInEditor("My JSON Object");
where parameter string is name that will appear in debug window.

In Unity Editor, open debug window from menu
Window -> Total JSON -> JSON Runtime Debug
Your objects and their content will appear in window.

Debugging in production

For easier problem tracking, you can add Debug ID strings to JSON objects. That ID is printed out in any exceptions that may happen during parsing or handling JSON objects.

This way you know which JSON object of all possible objects is causing the exception, even when there isn't any kind of stacktrace available.

JSON validator

You can open JSON validator from Unity Editor menu
Window -> Total JSON -> JSON Validator

To this window you can copy&paste JSON objects or arrays and click Validate button. Not only this will check that JSON is in valid format, but it will also make it much more readable by adding indents and line feeds.

Validator will also make extra effort trying to remove leading or trailing texts that are not part of JSON object. So you can for example copy text directly from Unity Console with stack traces. As long as there is some JSON object in the text.

Customized string output

When turning JSON object to string using CreateString() method, it is possible to customize output string using CreateStringSettings.

For example:
string customOutput = json.CreateString( new CreateStringSettings() {
  HumanReadable = true,
  NewLine = CreateStringSettings.NewLineTypes.LF
});

Protecting JSON objects

You can set JSON or JArray objects protected using
json.SetProtected();

This will set this JSON object and all other objects it contains to write protected. Nothing can be added, moved or changed. This is useful to make sure no accidental changes are made to objects that should be only for reading.


Full API docs

Full API documentation


Where to get

Download from Unity Asset Store