question

Brian Palma avatar image
Brian Palma asked

JSON Deserialization.

I just upgraded my PlayFab SDK to the newest version from one that was over four months old and after fixing a few lines of code it seems everything is working properly, except for a JSON deserialize method which is supposed to deserialize custom info from the catalog, the problem occurs on the line below.

Dictionary<string, string> customData = JsonReader.Deserialize<Dictionary<string, string>>(items[i].CustomData);

This deserialization has worked fine before the SDK update, after snooping around the json library it seems the Deserialize method was moved to JsonSerializer.cs yet the only way I can access that method is if I create a new instance of the jsonserializer and even then I'm getting an expression type error, it wants a jsonreader type not string.

I'm not really well versed with json serialization so I'm out of my element here and not sure if I'm just missing something small.

 

Thanks.

-Brian

 

 

 

 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Brian Palma avatar image
Brian Palma answered

I found I need to use JsonConvert.DeserializeObject<T>

Everything is all good now.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1807605288 avatar image
1807605288 answered

Hello!

A few of us discussed this thread, and there's a few things we can say:

We updated our Json serializer a few months ago, so if you updated your PlayFab SDK from an older one, you may have 2 json libraries in your project.  The old one has compatibility issues with devices, which is why we had to make the change.

If you have both json libraries in your project, you should try to remove the old one, because, as I said, it has issues when compiled to devices, such as windows phone.

It looks like Unity has JUST released its own json parsing library, which hopefully fixes and supports some of the compatibility issues we've seen with other solutions.  We have the problem of trying to support reverse compatibility (IE older versions of Unity, before their new json library), so it may be a while before we try to convert to their system.

In the end, it looks like you found a way to deserialize your data.  We'll have a more appropriate and well-documented solution once we tackle the new built-in Unity json serialization.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.