Json.NET under Unity3d for iOS

We use MiniJson and so far it serves our json needs well :)


You can use netstandard version of Newtonsoft.Json in Unity and it works fine. It seams that this library has changed some inner implementations to not use System.Reflection.Emit for deserialization anymore. Just be sure that after downloading nuget package you get Newtonsoft.Json.dll from netstandard2.0 folder, not from net45. And also don't forget to specify in link.xml that System.Linq.Expressions.Interpreter.LightLambda class shouldn't be stripped (it's used for deserialization) along with libraries/classes that you use for deserialization (to preserve constructors). Your link.xml should look smth like this:

<linker>
    <assembly fullname="Your.Dto.Package.Name" preserve="all" />
    <assembly fullname="System.Core">
        <type fullname="System.Linq.Expressions.Interpreter.LightLambda" preserve="all" />
    </assembly>
</linker>

We use this library in all our projects for Android and iOS with IL2CPP and Mono runtimes. Moreover, unlike Unity's JsonUtility, Newtonsoft.Json fully supports any type of objects, including Dictionary.

Microsoft Example


Newtonsoft Json fails AOT in iOS and also fails at deserializing anything inheriting from KeyedCollection in the webplayer. Here's a version that has been fixed:

JSON .NET For Unity (Supports iOS)