Skip to content

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

Open

Description

@SocratesDz

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?

Activity

  1. charafau commented on Aug 13, 2018

    @charafau
    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.

  2. SocratesDz commented on Aug 14, 2018

    @SocratesDz
    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.

  3. charafau commented on Oct 2, 2018

    @charafau
    Owner

    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

  4. SocratesDz commented on Oct 3, 2018

    @SocratesDz
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions