applejag / Newtonsoft.Json-for-Unity

Newtonsoft.Json (Json.NET) 10.0.3, 11.0.2, 12.0.3, & 13.0.1 for Unity IL2CPP builds, available via Unity Package Manager
https://github.com/jilleJr/Newtonsoft.Json-for-Unity
MIT License
1.16k stars 131 forks source link

No compilation errors but JSONSerialze generated data returns BadRequest status code in Android #146

Open apar945 opened 2 years ago

apar945 commented 2 years ago

Hello,

I have read through the documentation, tried AOT "preserve-all" method, reviewed many open/closed tickets. However, my unity application does not work when compiled with IL2CPP scripting backend. We use Json for exchange data via APIs running in an AWS backend. When compiled with Mono, they work fine. But Google Play requires Armv64 support in your build to be allowed to publish the app. So we compiled a version with IL2CPP and there were no compile time issues. However, the Newtonsoft.Json dependent code does not work properly. I have tried version 13.0.102 of the release.

What could I try to get this to work? Any suggestions would be appreciated.

Regards Ankit

applejag commented 2 years ago

Hello @apar945! Nice of you to have tried reading up, that is such a great start!

Could you possibly get the error logs from the android build? It can sometimes be tricky, but making a development build should be a good start. Then the errors should be shown on screen and on connected PC inside Unity I believe.

If you could also provide the C# code and class used to serialize or deserialize then that'd be awesome. :) So I know which edge cases you might be hitting on.

apar945 commented 2 years ago

Hello @jilleJr I was using a DLL which was referring to Newtonsoft.Json dll. I brought the code for the dll into the project and then tried serialising the data and calling the API and it all worked. So it seems like loading the json calls from another DLL, built in .Net targeting .Net Standard 2.0, was not working. I will now test all areas of the application which use this call to confirm if functionality is broken.

Update: I just checked that I have been testing with unity newtonsoft package 3.0.1 today so that has been working and I am sure your package would also work as the unity package is fork of it.

Regards Ankit