diff --git a/CHANGES.markdown b/CHANGES.markdown index a8e4eab..18d0a59 100644 --- a/CHANGES.markdown +++ b/CHANGES.markdown @@ -2,6 +2,7 @@ v1.4 * radically refactored decoder * `dirty_strings` now behaves intuitively in decoding. bad codepoints, bad utf8, illegal characters and escapes (except `"` and `'` if `single_quoted_strings` is enabled) are ignored completely +* `incomplete_handler` & `error_handler` are now available for use, see documentation in README v1.3.3 diff --git a/README.markdown b/README.markdown index 8010910..ff26996 100644 --- a/README.markdown +++ b/README.markdown @@ -301,6 +301,20 @@ jsx functions all take a common set of options. not all flags have meaning in al relax is a synonym for `[replaced_bad_utf8, single_quoted_strings, comments, ignored_bad_escapes]` for when you don't care how janky and awful your json input is, you just want the parser to do the best it can +- `incomplete_handler` & `error_handler` + + the default incomplete and error handlers can be replaced with user defined handlers. if options include `{error_handler, F}` and/or `{incomplete_handler, F}` where `F` is a function of arity 3 they will be called instead of the default handler. the spec for `F` is as follows + ```erlang + F(Remaining, InternalState, Config) -> any() + + Remaining = binary() | term() + InternalState = any() + Config = tuple() + ``` + `Remaining` is the binary fragment or term that caused the error + `InternalState` is an opaque structure containing the internal state of the parser/decoder/encoder + `Config` is a list of options/flags in use by the parser/decoder/encoder + ## exports ##