Unity, How to get child property values from response scriptData
M
Michael Kielb
started a topic
almost 7 years ago
Hello,
I'm stuck and can't find any documentation on this even though it must be pretty common. I need to get child properties from my scriptData responses. In my code below I can get all the top level property values, but I can't dig down and get their child properties. The code I get to pull the main property values is below, and I also showed some example data of what I need to retrieve.
GSData data = response.ScriptData; object[] levelsList = data.GetObjectList("playerCreatedLevels").ToArray();
foreach(var find in levelsList){ var dic = (Dictionary<string, object>)find; string levelName = dic["playerName"].ToString(); //This works good for getting a top level properties, but how do I get a child of playerName or any other main property if exists?
"_id": {
"$oid": "#####" <-----Need this but, don't know how to get
},
"playerId": "#####", <------Already able to get this
"playerName": "example user", <------Already able to get this
"Contents": {
"Size": {
"Width": "64", <-----Need this but, don't know how to get
"Height": "64" <-----Need this but, don't know how to get
},
Best Answer
R
Ryan Fuller
said
almost 7 years ago
Get getobject and getobjectlist are deprectaed and you should switch to using getgsdata and getgsdatalist, and access values with the gsdata "get" methods. In your case it would be something like this:
Get getobject and getobjectlist are deprectaed and you should switch to using getgsdata and getgsdatalist, and access values with the gsdata "get" methods. In your case it would be something like this:
Michael Kielb
Hello,
I'm stuck and can't find any documentation on this even though it must be pretty common. I need to get child properties from my scriptData responses. In my code below I can get all the top level property values, but I can't dig down and get their child properties. The code I get to pull the main property values is below, and I also showed some example data of what I need to retrieve.
GSData data = response.ScriptData;
object[] levelsList = data.GetObjectList("playerCreatedLevels").ToArray();
foreach(var find in levelsList){
var dic = (Dictionary<string, object>)find;
string levelName = dic["playerName"].ToString(); //This works good for getting a top level properties, but how do I get a child of playerName or any other main property if exists?
Get getobject and getobjectlist are deprectaed and you should switch to using getgsdata and getgsdatalist, and access values with the gsdata "get" methods. In your case it would be something like this:
Ryan Fuller
Get getobject and getobjectlist are deprectaed and you should switch to using getgsdata and getgsdatalist, and access values with the gsdata "get" methods. In your case it would be something like this:
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics