example modules using new api

This commit is contained in:
alisdair sullivan 2010-05-30 16:39:58 -07:00
parent 2bc885f3c4
commit e24d7e7a3e
3 changed files with 25 additions and 23 deletions

View file

@ -35,12 +35,11 @@
pretty(JSON, Opts) ->
Init = init(parse_opts(Opts, #opts{})),
P = jsx:decoder({{jsx_prettify, jsx_event}, Init}, []),
try
{Result, _} = P(JSON),
Result
catch
_:_ -> throw(badarg)
end.
case P(JSON) of
{incomplete, _} -> {error, badjson}
; {error, badjson} -> {error, badjson}
; {Result, _} -> Result
end.
parse_opts([{indent, Val}|Rest], Opts) ->