i-json
i-json copied to clipboard
Appears to throw for both programmer and operational errors
I'd be nice if this library had a parser.result()
vs parser.error()
instead of throwing on invalid JSON.
Well, I wanted to keep the API as simple as possible. More sophisticated APIs can always be scaffolded around this one. It would be very easy to wrap it with an evented API that emits result and error events.
One thing I should do though is throw different exception types. Today it's all Error
.
Thinking more about this, it would not be too hard to add an optional error callback to createParser. Only syntax errors would go through this callback. Programmer errors would still be thrown.