Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poor JsonUtility from UnityEngine #11

Closed
davidorbelian opened this issue Feb 27, 2018 · 11 comments
Closed

Poor JsonUtility from UnityEngine #11

davidorbelian opened this issue Feb 27, 2018 · 11 comments

Comments

@davidorbelian
Copy link

davidorbelian commented Feb 27, 2018

@jdnichollsc One more thing.

I have tried to POST some data to my ASP.NET Core API and every time ModelBinder from MVC failed to bind the incoming JSON to my model object. After some hours of debugging I tried to replace the JsonUtility to JsonConvert from Newtonsoft.Json package and it worked.

Also I can say, that JsonUtility can not serialize/deserialize dictionaries, which is important for me.

The dark side of that (I am not sure) is that JsonUtility may be faster, but I don't think it can compensate missing features or (in my case) just not working with my API (The problem is not from there, because Postman and Swagger working OK when testing).

You will not have any troubles with .NET Framework version, Newtonsoft requires .NET Framework 2.0.

What do you think about this?

@jdnichollsc
Copy link
Member

jdnichollsc commented Mar 4, 2018

JsonUtility is used in Unity because Newtonsoft is not supported in all platforms, check the following link:

Also, I can't see any oficial documentation to integrate Newtonsoft with Unity without issues, and I can't debug all platforms, sorry man

@jdnichollsc
Copy link
Member

@davidorbelian If you want, you can create a pull request with the changes and we can have other branch of this library, but the master is the most stable version

@davidorbelian
Copy link
Author

@jdnichollsc sure I can create a PR. I think Unity limitations are very sick in this case. I already forked this and changed the JSON utility to use in my project, I will create a PR when finish code cleanup (It's targeting experimental .NET 4.6 in Unity and is planned to be only the desktop build). May be I can figure out how to fix the JsonUtility issues.
Thank you.

@jdnichollsc
Copy link
Member

@davidorbelian check the last version, some fixes were added, thanks for your help! 👍

@jdnichollsc
Copy link
Member

@davidorbelian By other hand, can you attach any example of your models?

@jdnichollsc
Copy link
Member

@davidorbelian try this other package https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347
Let me know what you think

@davidorbelian
Copy link
Author

@jdnichollsc I will look at this at weekend. Sorry for so late answer.

@jdnichollsc
Copy link
Member

jdnichollsc commented Mar 15, 2018

@davidorbelian No problem, check my example with NodeJS https://github.com/proyecto26/RestClient#example

@jdnichollsc
Copy link
Member

@davidorbelian A moment ago, I reverted all the changes from the master branch to create a pull request to compare with the previous version of the plugin, I'm going to add a property BodyString from the RequestHelper class to send your JSON if you want to use other tool to serialize the code, so let me do that change and improve the code, any comments are really apreciated

Pull request => #18

Regards, Nicholls

@jdnichollsc
Copy link
Member

Check my friend the files modified, thanks for your help and patience! 💯 https://github.com/proyecto26/RestClient/pull/18/files

@jdnichollsc jdnichollsc added this to Done in Development May 19, 2018
@jdnichollsc
Copy link
Member

@davidorbelian any good comment from the Unity Asset Store would be really appreciated :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants