charafau/json2builtvalue

Exception raised when parsing null values or empty lists.

Opened this issue · 4 comments

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.

I understand, at first I was wondering what datatype you should return. But as the null value is unknown, I guess dynamic would fit better.

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

I see it fit, if there's null, you could skip it.