updated examples for new api
This commit is contained in:
parent
f042908c30
commit
38aef5f383
4 changed files with 4 additions and 4 deletions
|
@ -34,7 +34,7 @@
|
||||||
%% also is not streaming, though it could be modified to parse partial objects/lists.
|
%% also is not streaming, though it could be modified to parse partial objects/lists.
|
||||||
|
|
||||||
decode(JSON) ->
|
decode(JSON) ->
|
||||||
P = jsx:decoder({jsx_parser, event, []}, []),
|
P = jsx:parser({jsx_parser, event, []}, []),
|
||||||
case P(JSON) of
|
case P(JSON) of
|
||||||
{incomplete, _} ->
|
{incomplete, _} ->
|
||||||
{error, badjson}
|
{error, badjson}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
pretty(JSON, Opts) ->
|
pretty(JSON, Opts) ->
|
||||||
Init = init(parse_opts(Opts, #opts{})),
|
Init = init(parse_opts(Opts, #opts{})),
|
||||||
P = jsx:decoder({jsx_prettify, prettify, Init}, []),
|
P = jsx:parser({jsx_prettify, prettify, Init}, []),
|
||||||
case P(JSON) of
|
case P(JSON) of
|
||||||
{incomplete, _} -> {error, badjson}
|
{incomplete, _} -> {error, badjson}
|
||||||
; {error, badjson} -> {error, badjson}
|
; {error, badjson} -> {error, badjson}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
-export([decoder/1, event/2]).
|
-export([decoder/1, event/2]).
|
||||||
|
|
||||||
decoder(Opts) ->
|
decoder(Opts) ->
|
||||||
Decoder = jsx:decoder({jsx_stream_parser, event, 0}, Opts),
|
Decoder = jsx:parser({jsx_stream_parser, event, 0}, Opts),
|
||||||
fun(Stream) -> try
|
fun(Stream) -> try
|
||||||
case Decoder(Stream) of
|
case Decoder(Stream) of
|
||||||
{incomplete, F} -> {incomplete, F}
|
{incomplete, F} -> {incomplete, F}
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
%% also is not streaming, though it could be modified to parse partial objects/lists.
|
%% also is not streaming, though it could be modified to parse partial objects/lists.
|
||||||
|
|
||||||
is_json(JSON) ->
|
is_json(JSON) ->
|
||||||
P = jsx:decoder({jsx_verify, event, ok}, []),
|
P = jsx:parser({jsx_verify, event, ok}, []),
|
||||||
case P(JSON) of
|
case P(JSON) of
|
||||||
{incomplete, _} ->
|
{incomplete, _} ->
|
||||||
false
|
false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue