Hi, I've tried to use CloudScript to parse to an JSON object but it didn't work anymore. I want a JSON object but always get the string.
Note that the "inventory" in my code is my own custom inventory, not the Playfab built-in inventory
Typescript
let inventoryInternalData = server.GetUserInternalData({ PlayFabId:currentPlayerId, Keys: ["inventoryKey"] }).Data; try { response.inventory = JSON.parse(JSON.stringify(inventoryInternalData)); } catch (e) { log.debug(e); }
Internal json object
{ "myFile.txtInventory": { "__type": "Gokyo.Inventory.ItemCollectionSerializationModel,Assembly-CSharp", "value": { "items": [ { "itemID": 12, "amount": 1, "collectionName": "Inventory", "upgradable": true, "currentLevel": 22, "rarityID": 0 }, { "itemID": 12, "amount": 1, "collectionName": "Inventory", "upgradable": true, "currentLevel": 10, "rarityID": 0 }, { "itemID": 1, "amount": 2, "collectionName": "", "upgradable": false, "currentLevel": 0, "rarityID": -1 } ], "currencies": [ { "currencyID": 0, "amount": 4444 }, { "currencyID": 1, "amount": 0 } ] } } }
The return result response.inventory
"inventory": { "inventoryKey": { "Value": "{\"myFile.txtInventory\":{\"__type\":\"Gokyo.Inventory.ItemCollectionSerializationModel,Assembly-CSharp\",\"value\":{\"items\":[{\"itemID\":12,\"amount\":1,\"collectionName\":\"Inventory\",\"upgradable\":true,\"currentLevel\":22,\"rarityID\":0},{\"itemID\":12,\"amount\":1,\"collectionName\":\"Inventory\",\"upgradable\":true,\"currentLevel\":10,\"rarityID\":0},{\"itemID\":1,\"amount\":2,\"collectionName\":\"\",\"upgradable\":false,\"currentLevel\":0,\"rarityID\":-1}],\"currencies\":[{\"currencyID\":0,\"amount\":4444},{\"currencyID\":1,\"amount\":0}]}}}", "LastUpdated": "2020-05-02T13:28:01.722Z", "Permission": "Private" } }
I've tried to parse with a json editor. It works fine
,