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

Nulls in maps? #6

Closed
zsperske opened this issue Nov 1, 2017 · 2 comments
Closed

Nulls in maps? #6

zsperske opened this issue Nov 1, 2017 · 2 comments

Comments

@zsperske
Copy link
Collaborator

zsperske commented Nov 1, 2017

@ndtaylor I'm working on adding support for null values in maps and have come up with this test data.

"myStringMapWithSingleNullValue": { "key1": null }, "myStringMapWithNullValues": { "key1": null, "key2": "value2", "key3": "null" }, "myObjectMapWithNullValues": { "key1": { "myString": null }, "key2": { null }, "key3": { "myString": "value2" }, "key4": { "myString": "null" } }

"key2" in the object map isn't valid JSON. Is there a way to represent a null value in a case like this? A little background, we're trying to use JsonSelfValues to parse every field of a model, so we can determine how much we aren't parsing (and make some decisions based on that). We ran into nulls in an unparsed array which caused a crash, and I'm trying to proactively add support for nulls in maps (though we haven't seen them).

I don't think we should be making autoparse silently swallow malformed json like "key2", but would it be possible/reasonable for JsonSelfValues to not crash?

@ndtaylor
Copy link
Contributor

ndtaylor commented Nov 2, 2017

Short answer, no, I don't think it's reasonable to not crash on invalid JSON, because there's no guaranteed way to finish parsing a document that has invalid JSON. If you want to parse everything except the problem section, you would need to use some other library to fix the input before you give it to Autoparse (or, you know, tell whoever is sending you that JSON to fix it). Having Autoparse deal with it is, I think, outside of its scope.

I would argue that "key2": { null } just isn't a valid test case. The value for key2 is an object (which is valid), but the contents of the object are just random characters (which is invalid).

@zsperske
Copy link
Collaborator Author

zsperske commented Nov 3, 2017

I agree that it isn't a valid test case, closing this issue.

@zsperske zsperske closed this as completed Nov 3, 2017
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