- Home /
Deserializing Json problem in Hololens app
Hi,
I have been trying to deserialize a json inside a hololens app that is developed by Unity 2018.2.17.f1 having il2cpp scripting backend and .net 4.x target framework.
I have tried Newtonsoft json library and Unity`s JsonUtility library, but could not achieve because of the following errors:
Newtonsoft: Configuration error JsonUtility: could not deserialize nested arrays
An example json is below:
{"RetVal":true,
"UserId":"d14ba708-5faf-4827-86b1-21468dfd35d2",
"Role":"Operator",
"Processes":[
{"Id":"e5b16261-7756-436b-a928-b9d50e341579",
"Name":"Process Test",
"Description":"Process Test Description",
"VideoURL":"~/Content/Files/e5b16261-7756-436b-a928-b9d50e341579.mp4",
"TaskCount":12,
"SubtaskCount":12,
"Tasks":null}] }
I also tried JToken but I got exception again when running on the device.
My implementation for each of these libraries works perfect in Unity editor. But when I deploy the app into Hololens, it crashes when trying to deserialize a json.
Any help is appriciated. Thanks
Answer by Legend_Bacon · Nov 23, 2018 at 06:02 PM
Hello there,
Yeah, by default you shouldn't be using JsonUtility for anything that has more than 1 depth.
I have never used Newtonsoft, but I can recommend SimpleJSON. I use it pretty much on all my projects, and it has not failed me yet.
It has a steep-ish learning curve, but once you're over that it's pretty powerful.
Hope that helps!
Cheers,
~LegendBacon
It was complicated but worked great on Hololens. Thank you so much
Now the problem is about serializing a byte array holding an image data into a json string. Have you tried this before?