Json
A lightweight extension that provides asynchronous JSON serialization and validation functionality, specifically designed for Unity projects.
What is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format. It's easy for humans to read and write, and easy for machines to parse and generate. JSON is language-independent and has become one of the most popular data formats for web services and APIs.
Features
Asynchronous JSON serialization and deserialization
Built-in reference loop handling
Unity TextAsset support
JSON validation
Cancellation support
Requiring com.unity.nuget.newtonsoft-json 3.2.1 or above.
Json Converters
Followings data types of Json Converter are provided in AceLand.Library.Json.Converters
, and used in JsonExtension by default.
AnimationCurve
Bounds
BoundsInt
Color
Gradient
Hash128
LayerMask
Matrix4x4
Quaternion
RectInt
Rect
Vector2
Vector2Int
Vector3
Vector3Int
Vector4
Create a Serializable Object for Newtonsoft.Json
Serialization (Object to JSON)
Deserialization (JSON to Object)
JSON Validation
Error Handling
Serialization and deserialization operations include proper error handling
Detailed error messages include both operation type and data type information
Supports cancellation through CancellationToken
Best Practices
Always use cancellation tokens for long-running operations
Check JSON validity before deserialization in production code
Handle potential exceptions in async operations
Use TextAsset methods for Unity resource files
Using with Promise Awaiter
Benefits of Promise Awaiter
Avoid async/await syntax complexity
Clean callback-based code structure
Better error handling chain
Easier to manage multiple asynchronous operations
Last updated