question

ismediagames avatar image
ismediagames asked

Hi, I got a question about deserializing a result from playfab.

This is the string I receive from Playfab from result.FunctionResult.ToString().

"\"[{\\\"PlayFabId\\\":\\\"1C5BD2AB86B747B9\\\",\\\"Result\\\":true,\\\"ItemId\\\":\\\"Silver_CheckInChest\\\",\\\"ItemInstanceId\\\":\\\"4DB10C5AB87A4465\\\",\\\"ItemClass\\\":\\\"CheckInReward\\\",\\\"PurchaseDate\\\":\\\"2020-08-26T09:17:05.339Z\\\",\\\"Expiration\\\":\\\"2020-08-26T09:17:08.339Z\\\",\\\"Annotation\\\":\\\"Granted for logging in over 1 consecutive days.\\\",\\\"CatalogVersion\\\":\\\"DailyRewards\\\",\\\"DisplayName\\\":\\\"Silver feather chest\\\",\\\"UnitPrice\\\":0,\\\"BundleContents\\\":[]}]\""

But the code that I have throws Invalid cast from 'System.String' to 'System.Collections.Generic.List

when I use the deserializer for the List type ItemInstance. What could be the issue?

        List<ItemInstance> grantedItems = PlayFabSimpleJson.DeserializeObject<List<ItemInstance>>(result.FunctionResult.ToString());
CloudScript
10 |1200

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

1 Answer

·
ismediagames avatar image
ismediagames answered

Never mind, figured it out. JSON was double stringified from the cloud script.

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.