Json.NET under Unity3d for iOS

后端 未结 7 1467
你的背包
你的背包 2021-02-20 06:37

has anyone succeeded to adapt/port Json.NET to a version able to run under Unity3d deployed to iOS (and the webplayer, and android, too, but these seem less problematic), someho

7条回答
  •  臣服心动
    2021-02-20 06:47

    This question is a bit old but I wanted to share my experience. You can use netstandard version of Newtonsoft.Json in Unity and it works fine (at least in 2018 and higher versions). 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:

    
        
        
            
        
    
    

    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

提交回复
热议问题