example modules using new api
This commit is contained in:
parent
2bc885f3c4
commit
e24d7e7a3e
3 changed files with 25 additions and 23 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue