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 inside single object or variable breaks the whole process of parsing. #53
Comments
Hi, thanks for your report. Can you share an example of the json that is triggering the fail? It will be easier for me to check what is failing and what can be done...thank you |
@javiercbk I have been using this conversion for my app since beginning. Sometime the backend returns different data type mainly like instead of String we are getting int or reverse. So it cause exception and break the whole process of parsing. So basically I want is whenever such exception occurs I just want to assign a value like null instead of failing whole process. |
Let me see if I am understanding correctly. Currently you are generating your dart classes using this tool with this sample json: {
"strProp": "server sends a string here"
} So you generate your parser and things are looking good, until one day the you get this json: {
"strProp": 123
} The code generated by this library will throw an exception whenever you attempt to parse an int as a string. If this is currently your problem, and forgive me if I am not understanding correctly, then you have bigger problems. I doubt that any library can handle an API contract change (in this case sending an int instead of a string). You can grab those properties you know might change their type to Aside from that, I'm really out of ideas. Although this library is prepared to make type hinting and some other nice stuff, I found myself with little time to keep on adding features to something that currently gets a developer 80% close to the goal of parsing json. This library generates code that aims to be performant because I use it to generate parsers for my mobile applications, I could have added some type assertion and do my best to save you from these cases, but that would make things:
Did I nailed on the issue? If I did, what ideas do you have for solving this issue for future users? Thanks |
How can we handle exception during parsing, so that it doesn't breaks the whole process of parsing, instead assign null value to that variable or object?
The text was updated successfully, but these errors were encountered: