response.ScriptData.GetGSDataList("slots") gives me a list with Count = 2. So the null objects are filtered out. They are included in the underlying dictionary though.
Is this by design or a bug? I would expect an unfiltered list as return value.
Best Answer
D
David Brandes
said
about 7 years ago
It took a while to find this behaviour as the cause for some bugs in our game. But I implemented a workaround:
List<GSData> GetUnfilteredGSDataList (GSData data, string key)
{
var objectList = data.BaseData [key] as List<object>;
var gsDataList = new List<GSData> ();
if (null != objectList)
{
foreach (Dictionary<string, object> obj in objectList)
{
gsDataList.Add ( null == obj ? null : new GSData (obj));
}
}
return gsDataList;
}
Im going to check with our tech-guys as to how GetGSDataList retrieves these elements, but i presume the problem is that a null object cannot be parsed as an object even-though it can recognize the 'slots' array as having a certain number of elements.
Is this causing problems for you in your game? Please let us know,
Thanks, Sean
D
David Brandes
said
about 7 years ago
Answer
It took a while to find this behaviour as the cause for some bugs in our game. But I implemented a workaround:
List<GSData> GetUnfilteredGSDataList (GSData data, string key)
{
var objectList = data.BaseData [key] as List<object>;
var gsDataList = new List<GSData> ();
if (null != objectList)
{
foreach (Dictionary<string, object> obj in objectList)
{
gsDataList.Add ( null == obj ? null : new GSData (obj));
}
}
return gsDataList;
}
R
Rich Joslin
said
about 7 years ago
This really put a kink in things for me. I'm trying to work around it using {} but that's not ideal.
R
Rich Joslin
said
about 7 years ago
Also, {} won't work in an array of ints. I'll have to come up with a secret number to use to indicate where a null should be. I hope the null parsing thing gets fixed.
David Brandes
Hello,
I have something like the following object I set as script data in cloud code:
response.ScriptData.GetGSDataList("slots") gives me a list with Count = 2. So the null objects are filtered out. They are included in the underlying dictionary though.
Is this by design or a bug? I would expect an unfiltered list as return value.
It took a while to find this behaviour as the cause for some bugs in our game. But I implemented a workaround:
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Im going to check with our tech-guys as to how GetGSDataList retrieves these elements, but i presume the problem is that a null object cannot be parsed as an object even-though it can recognize the 'slots' array as having a certain number of elements.
Is this causing problems for you in your game?
Please let us know,
Thanks,
Sean
David Brandes
It took a while to find this behaviour as the cause for some bugs in our game. But I implemented a workaround:
Rich Joslin
This really put a kink in things for me. I'm trying to work around it using {} but that's not ideal.
Rich Joslin
Also, {} won't work in an array of ints. I'll have to come up with a secret number to use to indicate where a null should be. I hope the null parsing thing gets fixed.
-
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