JSON .NET for Unity

Json Serialization Support for Unity

Serialization is a fundamental building block for persisting and transporting object based data. JSON .NET is the #1 Json Serialization package for the .NET Framework. It has also been largely requested by the Unity Community. There are two options for purchasing JSON .NET For Unity, FastSpring and the Unity Asset Store. Users who purchase through my FastSpring store will receive an email notification with information to log into this site which gives access to downloads. You will also have instant access to the newest versions instead of waiting for the update to be approved by the Unity Asset Store. Purchases through FastSpring will include the same free updates within the purchased major version as purchases through the Unity Asset Store.

 

While many in the Unity Community have succeeded in getting JSON .NET to work for their games, it has never worked properly with iOS or IL2CPP. The iOS errors are due to incompatibilities with AOT (Ahead of Time Compilation) that is used by Mono/IL2CPP in iOS.

With my port of JSON .NET, I've corrected these issues, bringing full JSON .NET Support to Unity 4.6+, including iOS, Android, WebGL, Standalone PC, Linux, Mac, Xbox One, PS4, WiiU, Windows Universal (WSA), HoloLens and more. Serialization and Deserialization can now be accomplished with simple one line calls:

		var person = new Person();
		var serializedPerson = JsonConvert.SerializeObject(person);
		var newPerson = JsonConvert.DeserializeObject<Person>(serializedPerson);

Consistency is key and many other Assets that are already in the Asset Store use a JSON .NET DLL. Many of them are unaware that it breaks on AOT Platforms. I've maintained nearly all of the original namespaces and calling conventions to make JSON .NET for Unity a drop-in replacement for existing JSON .NET implementations. This means that you can simply delete the existing DLL and import my asset without making any code changes and in most cases it will just work.

Both Json and Bson are supported. This means you can binary encode your objects into Bson for object persistence and storage that's more difficult to tamper with.