Open Collective
Open Collective
Loading
New package of converters for Unity types
Published on June 1, 2020 by Kalle Fagerberg

I not long ago now got v1.0.0 ready for release of my package jilleJr/Newtonsoft.Json-for-Unity.Converters. The most common use-case for Newtonsoft.Json within Unity brings up the troubles of converting Unity's own types, such as just the simple Vector3, Quaternions, Color, etc. The reason we need custom converters for these types is that some of them has recursive paths, such as the Vector3.normalized instance property returning a Vector3, resulting in a loop where the serializer could try evaluate myVector3.normalized.normalized.normalized.normalized.normalized.normalized..... (and so on) into a tree, and at some point hitting a limit and erroring out.

The package contains code and help from numerous other champions in the field. I've had contact with and received help from Dustin Horne (aka. Parentelement, author of the original Json .NET package on Unity Assets Store) and Wanzyee Wang (aka. Wanzyee Studio, author of Json.NET Converters package on Unity Assets Store) and created this package as a result. Trying to learn from their known pitfalls as their packages has been in use for some time now.

Want to try it out?

First get the Newtonsoft.Json-for-Unity package added to your project, then add the converters package Newtonsoft.Json-for-Unity.Converters added right after.

Available on OpenUPM: https://openupm.com/packages/jillejr.newtonsoft.json-for-unity.converters/

Or install it via just UPM: https://github.com/jilleJr/Newtonsoft.Json-for-Unity/wiki/Install-Converters-via-UPM