You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exception raised when parsing null values or empty lists. #3
After trying to parse some json strings with https://charafau.github.io/json2builtvalue/, it throws a RangeError exception when trying to parse empty lists and null values, e.g.:
{ "a": 1, "b": 2, "c": [], "d": null }
Wouldn't it be better if you return dynamic types in this cases?
thanks for comment. To be honest I'm not sure what would be the best case to support this case, the point of model class is to have strong type (now even more with dart2). In my opinion generator should show error when json is not valid.
Sorry for wrong response, I usually don't put nulls in json so it takes me long to fix those. As for me it should probably skip that if someone put 'null' in json
Activity
charafau commentedon Aug 13, 2018
thanks for comment. To be honest I'm not sure what would be the best case to support this case, the point of model class is to have strong type (now even more with dart2). In my opinion generator should show error when json is not valid.
SocratesDz commentedon Aug 14, 2018
I understand, at first I was wondering what datatype you should return. But as the null value is unknown, I guess
dynamicwould fit better.charafau commentedon Oct 2, 2018
Sorry for wrong response, I usually don't put nulls in json so it takes me long to fix those. As for me it should probably skip that if someone put 'null' in json
SocratesDz commentedon Oct 3, 2018
I see it fit, if there's null, you could skip it.