From 697d14135a65df9b2b24c51c7e963109ad0ba259 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Thu, 27 May 2010 16:24:31 -0700 Subject: [PATCH] updated examples for new api, sort of. should have done all of this on a branch --- examples/jsx_parser.erl | 9 +++------ examples/jsx_prettify.erl | 7 ++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/examples/jsx_parser.erl b/examples/jsx_parser.erl index 3a25f33..7fd6c99 100644 --- a/examples/jsx_parser.erl +++ b/examples/jsx_parser.erl @@ -34,11 +34,8 @@ decode(JSON) -> P = jsx:decoder({{jsx_parser, event}, []}, []), try - {Result, Rest} = P(JSON), - case jsx:tail_clean(Rest) of - true -> Result - ; _ -> throw(badarg) - end + {Result, _} = P(JSON), + Result catch _:_ -> throw(badarg) end. @@ -68,7 +65,7 @@ event(end_array, [Array, Parent|Stack]) when is_list(Parent) -> event(end_object, [Object]) -> [Object]; event(end_array, [Array]) -> - [Array]; + [lists:reverse(Array)]; event({key, Key}, [Object|Stack]) -> [{key, Key}] ++ [Object] ++ Stack; diff --git a/examples/jsx_prettify.erl b/examples/jsx_prettify.erl index 8a28026..90b8007 100644 --- a/examples/jsx_prettify.erl +++ b/examples/jsx_prettify.erl @@ -36,11 +36,8 @@ pretty(JSON, Opts) -> Init = init(parse_opts(Opts, #opts{})), P = jsx:decoder({{jsx_prettify, jsx_event}, Init}, []), try - {Result, Rest} = P(JSON), - case jsx:tail_clean(Rest) of - true -> Result - ; _ -> throw(badarg) - end + {Result, _} = P(JSON), + Result catch _:_ -> throw(badarg) end.