I've been trying to make a data sync feature in my game. I use UserReadOnlyData to keep track of the progress for player challenges. I've noticed that the Userreadonlydata response outputs the data in a different format then title data. I have a function that works for all my title data but I can't seem to get it to work for the user data.
Example for titledata debug call
Debug.Log(result.Data["CharacterLevelRamp"]);result
{"1":250,"2":550,"3":900,"4":1550,"5":2200,"6":3050,"7":3900,"8":4500,"9":5150,"10":6400,"11":7850,"12":9100,"13":10400,"14":11950,"15":13250,"16":14700,"17":16350,"18":18100,"19":19900,"20":22000,"21":24450,"22":26900,"23":30000,"24":32500,"25":36100} UnityEngine.Debug:Log(Object)
Example for userreadonlydata debug call
Debug.Log(result.Data["ChallengeProgress"].Value);result
"{\"TotalSpeed\":0,\"SingleSpeed\":0,\"NoDQ\":0,\"ConsecutiveWins\":0,\"TotalRating\":0,\"TotalWins\":0,\"FriendWins\":0}" UnityEngine.Debug:Log(Object)
Both of these debugs were called in the success functions for both API calls.
The title data has a method that saves the "CharacterLevelRamp" to a dictionary <string, int>.
I want to do the same exact thing for the player read only data but can't find any documentation on the subject. I'm able to deserialize the second example but it just goes to a string and I'm not able to separate the values.
JSON file for first example -
"CharacterLevelRamp": "{\"1\":250,\"2\":550,\"3\":900,\"4\":1550,\"5\":2200,\"6\":3050,\"7\":3900,\"8\":4500,\"9\":5150,\"10\":6400,\"11\":7850,\"12\":9100,\"13\":10400,\"14\":11950,\"15\":13250,\"16\":14700,\"17\":16350,\"18\":18100,\"19\":19900,\"20\":22000,\"21\":24450,\"22\":26900,\"23\":30000,\"24\":32500,\"25\":36100}",
JSON file for the second example
"{\"TotalSpeed\":0,\"SingleSpeed\":0,\"NoDQ\":0,\"ConsecutiveWins\":0,\"TotalRating\":0,\"TotalWins\":0,\"FriendWins\":0}"
The method I'm using to convert the title data is
private void ExtractJsonData<T>(Dictionary<string, string> resultData, string titleKey, ref T output) { if (!resultData.TryGetValue(titleKey, out _)) Debug.LogError("Failed to load titleData: " + titleKey); try { output = JsonConvert.DeserializeObject<T>(resultData[titleKey]); } catch (Exception e) { Debug.LogError("Failed to load titleData: " + titleKey); Debug.LogException(e); } }
Just to summarize, putting the user read only data result into this doesn't work but the title data result works just fine in this function. How can I save user read only data KVPs into a dictionary for easy access?