You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"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?
The text was updated successfully, but these errors were encountered:
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).
@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?
The text was updated successfully, but these errors were encountered: