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

@ -28,15 +28,16 @@
decoder(Opts) ->
Decoder = jsx:decoder({{jsx_stream_parser, event}, 0}, Opts),
fun(Stream) ->
try Decoder(Stream) of
F when is_function(F) -> F
catch
throw:{ok, Result} -> Result
; throw:not_found -> not_found
; _:_ -> throw(badarg)
end
end.
fun(Stream) -> try
case Decoder(Stream) of
{incomplete, F} -> {incomplete, F}
; {error, badjson} -> {error, badjson}
end
catch
throw:{ok, Result} -> {ok, Result}
; throw:not_found -> {error, not_found}
end
end.
event(start_object, Level) ->
Level + 1;