Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception raised when parsing null values or empty lists. #3

Open
SocratesDz opened this issue Aug 5, 2018 · 4 comments
Open

Exception raised when parsing null values or empty lists. #3

SocratesDz opened this issue Aug 5, 2018 · 4 comments

Comments

@SocratesDz
Copy link

SocratesDz commented Aug 5, 2018

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?

@charafau
Copy link
Owner

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
Copy link
Author

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.

@charafau
Copy link
Owner

charafau commented 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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants