public interface begun
This commit is contained in:
parent
7468313ffc
commit
a932422d17
3 changed files with 37 additions and 2 deletions
34
src/jsx.erl
Normal file
34
src/jsx.erl
Normal file
|
@ -0,0 +1,34 @@
|
|||
-module(jsx).
|
||||
|
||||
-export([decoder/0, decoder/1]).
|
||||
|
||||
-include("../include/jsx.hrl").
|
||||
|
||||
decoder() ->
|
||||
decoder([]).
|
||||
|
||||
decoder(OptsList) ->
|
||||
OptsRec = parse_opts(OptsList),
|
||||
case OptsRec#opts.encoding of
|
||||
utf8 ->
|
||||
fun(Stream) -> jsx_utf8:start(Stream, [], [], OptsRec) end
|
||||
end.
|
||||
|
||||
|
||||
parse_opts(Opts) ->
|
||||
parse_opts(Opts, #opts{}).
|
||||
|
||||
parse_opts([], Opts) ->
|
||||
Opts;
|
||||
parse_opts([{comments, Value}|Rest], Opts) ->
|
||||
true = lists:member(Value, [true, false]),
|
||||
parse_opts(Rest, Opts#opts{comments = Value});
|
||||
parse_opts([{escaped_unicode, Value}|Rest], Opts) ->
|
||||
true = lists:member(Value, [ascii, codepoint, none]),
|
||||
parse_opts(Rest, Opts#opts{escaped_unicode = Value});
|
||||
parse_opts([{naked_values, Value}|Rest], Opts) ->
|
||||
true = lists:member(Value, [true, false]),
|
||||
parse_opts(Rest, Opts#opts{naked_values = Value});
|
||||
parse_opts([{encoding, Value}|Rest], Opts) ->
|
||||
true = lists:member(Value, [utf8]),
|
||||
parse_opts(Rest, Opts#opts{encoding = Value}).
|
Loading…
Add table
Add a link
Reference in a new issue