tightened up options allowed

This commit is contained in:
alisdair sullivan 2010-06-09 06:21:03 -07:00
parent 38aef5f383
commit e245d8aa92
2 changed files with 12 additions and 7 deletions

View file

@ -32,7 +32,7 @@
-spec decode(JSON::json()) -> {ok, [jsx_event(),...]} | {error, badjson}. -spec decode(JSON::json()) -> {ok, [jsx_event(),...]} | {error, badjson}.
-spec decode(JSON::json(), Opts::[any()]) -> {ok, [jsx_event(),...]} | {error, badjson}. -spec decode(JSON::json(), Opts::jsx_opts()) -> {ok, [jsx_event(),...]} | {error, badjson}.
decode(JSON) -> decode(JSON) ->
decode(JSON, []). decode(JSON, []).
@ -47,9 +47,9 @@ decode(JSON, Opts) ->
-spec parser() -> jsx_parser(). -spec parser() -> jsx_parser().
-spec parser(Opts::[any()]) -> jsx_parser(). -spec parser(Opts::jsx_opts()) -> jsx_parser().
-spec parser(Callbacks::{fun((jsx_event(), any()) -> any())}, Opts::[any()]) -> jsx_parser() -spec parser(Callbacks::{fun((jsx_event(), any()) -> any())}, Opts::jsx_opts()) -> jsx_parser()
; (Callbacks::{atom(), atom(), any()}, Opts::[any()]) -> jsx_parser(). ; (Callbacks::{atom(), atom(), any()}, Opts::jsx_opts()) -> jsx_parser().
parser() -> parser() ->
parser([]). parser([]).
@ -96,9 +96,7 @@ parse_opts([{escaped_unicode, Value}|Rest], {Comments, _EscapedUnicode, Stream})
parse_opts(Rest, {Comments, Value, Stream}); parse_opts(Rest, {Comments, Value, Stream});
parse_opts([{stream_mode, Value}|Rest], {Comments, EscapedUnicode, _Stream}) -> parse_opts([{stream_mode, Value}|Rest], {Comments, EscapedUnicode, _Stream}) ->
true = lists:member(Value, [true, false]), true = lists:member(Value, [true, false]),
parse_opts(Rest, {Comments, EscapedUnicode, Value}); parse_opts(Rest, {Comments, EscapedUnicode, Value}).
parse_opts([_UnknownOpt|Rest], Opts) ->
parse_opts(Rest, Opts).
%% first check to see if there's a bom, if not, use the rfc4627 method for determining %% first check to see if there's a bom, if not, use the rfc4627 method for determining

View file

@ -27,6 +27,13 @@
-type json() :: binary(). -type json() :: binary().
-type jsx_opts() :: [jsx_opt()].
-type jsx_opt() :: {comments, true | false}
| {escaped_unicode, ascii | codepoint | none}
| {stream_mode, true | false}
| {encoding, auto | utf8 | utf16 | utf16le | utf32 | utf32le }.
%% events emitted by the parser and component types %% events emitted by the parser and component types
-type unicode_codepoint() :: 0..16#10ffff. -type unicode_codepoint() :: 0..16#10ffff.