| .. | ||
| JSON.cs | ||
| JSON.cs.meta | ||
| README.md | ||
| README.md.meta | ||
LightJSON
LightJSON is a lightweight and optimized JSON parser written in C# for use in Unity games.
Conformance
LightJSON implements the ECMA-404 standard as closely as possible.
However, here are the (small) deviations from the full specification:
- Escaping characters with \u is not supported in strings
- Number parsing is not strictly as per the spec, but instead relies on System.Convert.ToDouble(). The implementation is very close to the spec, and supports exponents properly (e.g. 12.5e4)
Getting Started
The basic use case of parsing a JSON string is achieved through an API very similar to Javascript:
using LightJSON;
var json = JSON.Parse("{\"test\": 42}");
The resulting object is of class LightJSON.JSON, and can be used to extract or manipulate the parsed data:
// testValue will get 42.0
double testValue = json.GetField("test").NumberValue;
json.SetField("test", "hello");
To convert back to a string form, use the Stringify() method:
var str = JSON.Stringify(json);
License
MIT?