-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Is your feature request related to a problem? Please describe.
Not really.
Describe the solution you'd like
Instead of simply returning null when an attempt to decode fails, it would be cool if you could pass in a char[] which the function would populate with where the problem occurred (potentially on which line if it's pretty-printed JSON) and what happened, i.e. expected }, found ] on line 44.
Describe alternatives you've considered
n/a
Additional context
Users of get5 will sometimes - for reasons I don't understand, perhaps because they type in JSON manually - make mistakes in their files and not validate them, then ask us/me why their file doesn't load. If this library would tell them what kind of error they have made, it would help with debugging.
Also, while we're on JSON decoding, sm-json gets very confused when it decodes objects with duplicate keys, which is stupid, yes, but technically not invalid JSON - the last read key should determine the value of that key, and any others should be ignored/discarded. This caused one consumer of Get5 to have some very strange bugs because sm-json got the object wrong when asked to preserve ordered keys. I would propose it either return null or handle it correctly in that case.