From c3e0bae38fbdfbb630c1380d0d4907e6a46d3be6 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Mon, 4 Mar 2013 23:49:01 -0800 Subject: [PATCH] update README and CHANGES to take error_handler and incomplete_handler into consideration --- CHANGES.markdown | 1 + README.markdown | 14 ++++++++++++++ 2 files changed, 15 insertions(+) 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 ##