question

Jon avatar image
Jon asked

SetObjects with Json String results in invalid format in GameManager

When calling SetObjects with a json string as the payload, the resulting object is considered invalid json in the Game Manager UI.

```

{\"Version\":10}

```

This is not allowed if you try to manually insert this string via the console.

How do we work around this? It can serialize/de-serialize fine but does not play well with playfab console.


If I pass in the object to allow playfab (simpleJson) implementation to try and serialize it, then it will work with certain objects. But that json implementation is not smart enough for more complicated use cases.

var json = JsonConvert.SerializeObject(
    GameSave.PlayerDataCloud(), 
    Formatting.None,  
    new JsonSerializerSettings { 
        NullValueHandling = NullValueHandling.Ignore
    });

We use Json.net for some more customized serialization and also the annotations on our objects.

rqdbf.png (26.6 KiB)
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

·
Jon avatar image
Jon answered

Nevermind, figured it out.

For anyone else wondering:

As per the doc, just set the EscapedDataObject field instead of DataObject.

https://docs.microsoft.com/en-us/rest/api/playfab/data/object/setobjects?view=playfab-rest#setobject

var data = new List<SetObject>
{
    new SetObject()
    {
        ObjectName = "PlayerData",
        EscapedDataObject = json,
    }
};
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.