Json.NET under Unity3d for iOS

2019-04-07 20:26发布

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), somehow overcoming the AOT issues there?

Or are there plans to release a compatible version of Json.NET?

Many thanks,

Max

5条回答
Melony?
2楼-- · 2019-04-07 21:04

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

查看更多
劳资没心,怎么记你
3楼-- · 2019-04-07 21:09

Nope AFAIK.

LitJson and JsonFX would be alternate choice for Unity3D.

http://wiki.unity3d.com/index.php?title=UnityLitJSON

查看更多
我命由我不由天
4楼-- · 2019-04-07 21:13

Yes, we share code on client and server and use an older version when it was called NewtonSoft.Json. Works in IOS, Android, everything.

Search for NewtonSoft.Json, and you could probably find an archive.

查看更多
祖国的老花朵
5楼-- · 2019-04-07 21:18

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)

查看更多
放荡不羁爱自由
6楼-- · 2019-04-07 21:18

Have a look at the modified version of LitJson: UnityLitJson


Actually LitJson has some issues and is not always working as expected, so I created a simple JSON-Lib that can handle all Unity3D Types, Enums and arbitrary classes. Find it at GitHub: Tiny-JSON

You can use it very simple:

// encode
Animal a = new Animal(4);
string json = Json.Encode(a);

// decode
IList<Animal> a = Json.Decode<IList<Animal>>("[{\"legs\":4}, {\"legs\":2}]");
查看更多
登录 后发表回答