SmartJSON – Runtime JSON Toolkit


int health = json["player"]["health"].AsInt; Find multiple values using JSONPath: SmartJsonSelection names = json.SelectMany("$.player.inventory[*].name"); ... Custom converters


by Crazy Pixel Lab


Price History +

Standalone runtime JSON toolkit for Unity with JSONPath, typed models, mutation, async loading, Merge, Diff and JSON Patch.

• Unity version: 2019.4 LTS or newer

• Language level: C# 7.3 or newer

• API compatibility: .NET Standard 2.0 / .NET 4.x

• Full C# source code included

• No third-party dependencies

• Uses the built-in UnityWebRequest module for HTTP loading

• Render pipeline independent

• No shaders, materials or rendering components

• No required scenes, prefabs or runtime managers

• Runtime assembly and separate demo assembly included

• Works with standard JSON and JSON containing line/block comments

• Supports objects, arrays, strings, booleans, null and JSON numbers

• Numeric storage uses long, ulong, decimal or finite double as appropriate

• Supports one-dimensional and jagged arrays

• Supports List<T> and Dictionary<string, T>

• Supports public fields and public read/write properties

• Includes common Unity value-type conversion

• Custom conversion through ISmartJsonConverter

• JSONPath supports properties, indexes, wildcards, recursive descent, slices and filters

• JSON Patch supports Add, Remove and Replace operations

• Maximum recursive JSON depth: 128

• HTTP and Resources async loaders must be started from the Unity main thread

• Mutable JSON documents are not designed for concurrent writes

• Reflection-based model conversion in highly stripped IL2CPP builds may require preserving model types with Preserve or link.xml

• Included README contains API guidance, examples, limitations and advanced usage

• Included demo scene requires no additional packages

SmartJSON is a lightweight, standalone JSON toolkit designed for convenient runtime use in Unity.


Read deeply nested values with a clean node API:


int health = json["player"]["health"].AsInt;


Find multiple values using JSONPath:


SmartJsonSelection names =

json.SelectMany("$.player.inventory[*].name");


SmartJSON can load data from strings, TextAssets, Resources, files and HTTP. It supports synchronous and asynchronous workflows, cancellation, typed C# models and direct editing of the parsed JSON tree.


KEY FEATURES


• Simple navigation through objects and arrays

• Strongly typed primitive conversion

• JSONPath queries with SmartJsonSelection

• Conversion between JSON and C# models

• Runtime JSON mutation

• File, Resources, TextAsset and HTTP loading

• Async parsing and loading

• Custom converters

• Rename and ignore attributes

• Safe polymorphic serialization

• Line and block comments in JSON

• Deep cloning and equality comparison

• Deep and replacement merging

• JSON Diff generation

• JSON Patch with JSON Pointer paths

• Deterministic property ordering

• Pretty and compact JSON output


SmartJsonSelection provides Count, indexing, First, Last, FirstOrNull, LastOrNull, foreach enumeration and conversion of all matched values through AsArray<T>().


SmartJSON is suitable for game configuration, remote content, API responses, dialogue data, item databases, level definitions and other runtime data-driven systems.


The package has no dependency on Config Manager, requires no initialization component and does not add runtime GameObjects automatically.


A documented demo scene demonstrates local files, Resources, HTTP loading, JSONPath, SmartJsonSelection, mutation, cloning and serialization.