diff --git a/include/jsx.hrl b/include/jsx.hrl deleted file mode 100644 index 8bcb854..0000000 --- a/include/jsx.hrl +++ /dev/null @@ -1,42 +0,0 @@ -%% The MIT License - -%% Copyright (c) 2010 Alisdair Sullivan - -%% Permission is hereby granted, free of charge, to any person obtaining a copy -%% of this software and associated documentation files (the "Software"), to deal -%% in the Software without restriction, including without limitation the rights -%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -%% copies of the Software, and to permit persons to whom the Software is -%% furnished to do so, subject to the following conditions: - -%% The above copyright notice and this permission notice shall be included in -%% all copies or substantial portions of the Software. - -%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -%% THE SOFTWARE. - --include("jsx_common.hrl"). - - - --spec parser() -> jsx_parser(). --spec parser(Opts::jsx_opts()) -> jsx_parser(). - --spec term_to_json(JSON::eep0018()) -> binary(). --spec term_to_json(JSON::eep0018(), Opts::encoder_opts()) -> binary(). - --spec json_to_term(JSON::binary()) -> eep0018(). --spec json_to_term(JSON::binary(), Opts::decoder_opts()) -> eep0018(). - --spec is_json(JSON::binary()) -> true | false. --spec is_json(JSON::binary(), Opts::verify_opts()) -> true | false. - --spec format(JSON::binary()) -> binary() | iolist(). --spec format(JSON::binary(), Opts::format_opts()) -> binary() | iolist(). - --spec eventify(List::list()) -> jsx_parser_result(). diff --git a/include/jsx_common.hrl b/include/jsx_common.hrl index f8216b5..fdc6748 100644 --- a/include/jsx_common.hrl +++ b/include/jsx_common.hrl @@ -24,89 +24,4 @@ -define(is_utf_encoding(X), X == utf8; X == utf16; X == utf32; X == {utf16, little}; X == {utf32, little} -). - - --type jsx_opts() :: [jsx_opt()]. --type jsx_opt() :: {comments, true | false} - | {escaped_unicode, ascii | codepoint | none} - | {multi_term, true | false} - | {encoding, auto | utf8 | utf16 | {utf16, little} | utf32 | {utf32, little} }. - - -%% events emitted by the parser and component types --type unicode_codepoint() :: 0..16#10ffff. --type unicode_string() :: [unicode_codepoint()]. - --type jsx_event() :: start_object - | end_object - | start_array - | end_array - | end_json - | {key, unicode_string()} - | {string, unicode_string()} - | {integer, unicode_string()} - | {float, unicode_string()} - | {literal, true} - | {literal, false} - | {literal, null}. - - -%% this probably doesn't work properly --type jsx_parser() :: fun((binary()) -> jsx_parser_result()). - --type jsx_parser_result() :: {event, jsx_event(), fun(() -> jsx_parser_result())} - | {incomplete, jsx_parser()} - | {error, badjson}. - - --type supported_utf() :: utf8 | utf16 | {utf16, little} | utf32 | {utf32, little}. - - -%% eep0018 json specification --type eep0018() :: eep0018_object() | eep0018_array(). - --type eep0018_array() :: [eep0018_term()]. --type eep0018_object() :: [{eep0018_key(), eep0018_term()}]. - --type eep0018_key() :: binary() | atom(). - --type eep0018_term() :: eep0018_array() | eep0018_object() | eep0018_string() | eep0018_number() | true | false | null. - --type eep0018_string() :: binary(). - --type eep0018_number() :: float() | integer(). - - --type encoder_opts() :: [encoder_opt()]. --type encoder_opt() :: {strict, true | false} - | {encoding, supported_utf()} - | {space, integer()} - | space - | {indent, integer()} - | indent. - - --type decoder_opts() :: [decoder_opt()]. --type decoder_opt() :: {strict, true | false} - | {comments, true | false} - | {encoding, supported_utf()} - | {label, atom | binary | existing_atom} - | {float, true | false}. - - --type verify_opts() :: [verify_opt()]. --type verify_opt() :: {strict, true | false} - | {encoding, auto | supported_utf()} - | {comments, true | false}. - - --type format_opts() :: [format_opt()]. --type format_opt() :: {strict, true | false} - | {encoding, auto | supported_utf()} - | {comments, true | false} - | {space, integer()} - | space - | {indent, integer()} - | indent - | {output_encoding, supported_utf()}. \ No newline at end of file +). \ No newline at end of file diff --git a/include/jsx_decoder.hrl b/include/jsx_decoder.hrl index 20edf6e..b2a20c0 100644 --- a/include/jsx_decoder.hrl +++ b/include/jsx_decoder.hrl @@ -26,13 +26,6 @@ %% should take that into account --include("./include/jsx_common.hrl"). - - - --spec parser(OptsList::jsx_opts()) -> jsx_parser(). - - %% opts record for decoder -record(opts, { comments = false, diff --git a/include/jsx_eep0018.hrl b/include/jsx_eep0018.hrl deleted file mode 100644 index e759638..0000000 --- a/include/jsx_eep0018.hrl +++ /dev/null @@ -1,30 +0,0 @@ -%% The MIT License - -%% Copyright (c) 2010 Alisdair Sullivan - -%% Permission is hereby granted, free of charge, to any person obtaining a copy -%% of this software and associated documentation files (the "Software"), to deal -%% in the Software without restriction, including without limitation the rights -%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -%% copies of the Software, and to permit persons to whom the Software is -%% furnished to do so, subject to the following conditions: - -%% The above copyright notice and this permission notice shall be included in -%% all copies or substantial portions of the Software. - -%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -%% THE SOFTWARE. - --include("jsx_common.hrl"). - - - --spec json_to_term(JSON::binary(), Opts::decoder_opts()) -> eep0018(). - --spec term_to_json(JSON::eep0018(), Opts::encoder_opts()) -> binary(). - diff --git a/include/jsx_format.hrl b/include/jsx_format.hrl index 1086e3e..2746933 100644 --- a/include/jsx_format.hrl +++ b/include/jsx_format.hrl @@ -20,8 +20,6 @@ %% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN %% THE SOFTWARE. --include("jsx_common.hrl"). - -record(format_opts, { @@ -40,7 +38,4 @@ -define(start_object, ${). -define(end_object, $}). -define(start_array, $[). --define(end_array, $]). - - --spec format(JSON::binary(), Opts::format_opts()) -> binary() | iolist(). \ No newline at end of file +-define(end_array, $]). \ No newline at end of file diff --git a/include/jsx_verify.hrl b/include/jsx_verify.hrl deleted file mode 100644 index 2a33d80..0000000 --- a/include/jsx_verify.hrl +++ /dev/null @@ -1,27 +0,0 @@ -%% The MIT License - -%% Copyright (c) 2010 Alisdair Sullivan - -%% Permission is hereby granted, free of charge, to any person obtaining a copy -%% of this software and associated documentation files (the "Software"), to deal -%% in the Software without restriction, including without limitation the rights -%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -%% copies of the Software, and to permit persons to whom the Software is -%% furnished to do so, subject to the following conditions: - -%% The above copyright notice and this permission notice shall be included in -%% all copies or substantial portions of the Software. - -%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -%% THE SOFTWARE. - --include("jsx_common.hrl"). - - - --spec is_json(JSON::binary(), Opts::verify_opts()) -> true | false. \ No newline at end of file diff --git a/src/jsx.erl b/src/jsx.erl index 3dd8b29..225fffe 100644 --- a/src/jsx.erl +++ b/src/jsx.erl @@ -40,8 +40,7 @@ -export([eventify/1]). -%% function and type specifications --include("./include/jsx.hrl"). +-include("./include/jsx_common.hrl"). %% @type jsx_parser() = (binary()) -> jsx_parser_result(). diff --git a/src/jsx_eep0018.erl b/src/jsx_eep0018.erl index c71c40a..dc74469 100644 --- a/src/jsx_eep0018.erl +++ b/src/jsx_eep0018.erl @@ -32,7 +32,7 @@ -export([json_to_term/2, term_to_json/2]). --include("./include/jsx_eep0018.hrl"). +-include("./include/jsx_common.hrl"). -ifdef(TEST). diff --git a/src/jsx_format.erl b/src/jsx_format.erl index 4fa0145..c7de644 100644 --- a/src/jsx_format.erl +++ b/src/jsx_format.erl @@ -32,6 +32,7 @@ -export([format/2]). +-include("./include/jsx_common.hrl"). -include("./include/jsx_format.hrl"). diff --git a/src/jsx_utf16.erl b/src/jsx_utf16.erl index b211696..bb6ec8e 100644 --- a/src/jsx_utf16.erl +++ b/src/jsx_utf16.erl @@ -26,7 +26,10 @@ -module(jsx_utf16). + -define(utf16, true). + +-include("./include/jsx_common.hrl"). -include("./include/jsx_decoder.hrl"). %% i've noticed you've noticed that there's no source here. very astute. see diff --git a/src/jsx_utf16le.erl b/src/jsx_utf16le.erl index 1006634..bdcf16b 100644 --- a/src/jsx_utf16le.erl +++ b/src/jsx_utf16le.erl @@ -26,7 +26,10 @@ -module(jsx_utf16le). + -define(utf16le, true). + +-include("./include/jsx_common.hrl"). -include("./include/jsx_decoder.hrl"). %% i've noticed you've noticed that there's no source here. very astute. see diff --git a/src/jsx_utf32.erl b/src/jsx_utf32.erl index d82969e..230b301 100644 --- a/src/jsx_utf32.erl +++ b/src/jsx_utf32.erl @@ -26,7 +26,10 @@ -module(jsx_utf32). + -define(utf32, true). + +-include("./include/jsx_common.hrl"). -include("./include/jsx_decoder.hrl"). %% i've noticed you've noticed that there's no source here. very astute. see diff --git a/src/jsx_utf32le.erl b/src/jsx_utf32le.erl index 0f04d88..7c14fae 100644 --- a/src/jsx_utf32le.erl +++ b/src/jsx_utf32le.erl @@ -26,7 +26,10 @@ -module(jsx_utf32le). + -define(utf32le, true). + +-include("./include/jsx_common.hrl"). -include("./include/jsx_decoder.hrl"). %% i've noticed you've noticed that there's no source here. very astute. see diff --git a/src/jsx_utf8.erl b/src/jsx_utf8.erl index b609cdf..00052fa 100644 --- a/src/jsx_utf8.erl +++ b/src/jsx_utf8.erl @@ -26,7 +26,10 @@ -module(jsx_utf8). + -define(utf8, true). + +-include("./include/jsx_common.hrl"). -include("./include/jsx_decoder.hrl"). %% i've noticed you've noticed that there's no source here. very astute. see diff --git a/src/jsx_verify.erl b/src/jsx_verify.erl index 59ef574..afdfc45 100644 --- a/src/jsx_verify.erl +++ b/src/jsx_verify.erl @@ -32,7 +32,7 @@ -export([is_json/2]). --include("./include/jsx_verify.hrl"). +-include("./include/jsx_common.hrl"). -ifdef(TEST).