Browse Source

Remove `labels` alias for `keys`

Hynek Vychodil 8 years ago
parent
commit
cf825dd370
4 changed files with 4 additions and 9 deletions
  1. 2 2
      doc/jsone.md
  2. 2 3
      src/jsone.erl
  3. 0 3
      src/jsone_decode.erl
  4. 0 1
      test/jsone_decode_tests.erl

+ 2 - 2
doc/jsone.md

@@ -60,7 +60,7 @@ datetime_format() = iso8601
 
 
 
 
 <pre><code>
 <pre><code>
-decode_option() = {object_format, tuple | proplist | map} | {allow_ctrl_chars, boolean()} | {keys | labels, binary | atom | existing_atom | attempt_atom}
+decode_option() = {object_format, tuple | proplist | map} | {allow_ctrl_chars, boolean()} | {keys, binary | atom | existing_atom | attempt_atom}
 </code></pre>
 </code></pre>
 
 
 `object_format`: <br />
 `object_format`: <br />
@@ -76,7 +76,7 @@ decode_option() = {object_format, tuple | proplist | map} | {allow_ctrl_chars, b
 
 
 `keys`: <br />
 `keys`: <br />
 Defines way how object keys are decoded. The default value is `binary`.
 Defines way how object keys are decoded. The default value is `binary`.
-`labels` is alias compatible with `jsx`. <br />
+The option is compatible with `labels` option in `jsx`. <br />
 - `binary`: The key is left as a string which is encoded as binary. It's default
 - `binary`: The key is left as a string which is encoded as binary. It's default
 and backward compatible behaviour. <br />
 and backward compatible behaviour. <br />
 - `atom`: The key is converted to an atom. Results in `badarg` if Key value
 - `atom`: The key is converted to an atom. Results in `badarg` if Key value

+ 2 - 3
src/jsone.erl

@@ -218,8 +218,7 @@
 
 
 -type decode_option() :: {object_format, tuple | proplist | map}
 -type decode_option() :: {object_format, tuple | proplist | map}
                        | {allow_ctrl_chars, boolean()}
                        | {allow_ctrl_chars, boolean()}
-                       | {'keys' | 'labels', 'binary' | 'atom' |
-                          'existing_atom' | 'attempt_atom'}.
+                       | {'keys', 'binary' | 'atom' | 'existing_atom' | 'attempt_atom'}.
 %% `object_format': <br />
 %% `object_format': <br />
 %% - Decoded JSON object format <br />
 %% - Decoded JSON object format <br />
 %% - `tuple': An object is decoded as `{[]}' if it is empty, otherwise `{[{Key, Value}]}'. <br />
 %% - `tuple': An object is decoded as `{[]}' if it is empty, otherwise `{[{Key, Value}]}'. <br />
@@ -233,7 +232,7 @@
 %%
 %%
 %% `keys': <br />
 %% `keys': <br />
 %% Defines way how object keys are decoded. The default value is `binary'.
 %% Defines way how object keys are decoded. The default value is `binary'.
-%% `labels' is alias compatible with `jsx'. <br />
+%% The option is compatible with `labels' option in `jsx'. <br />
 %% - `binary': The key is left as a string which is encoded as binary. It's default
 %% - `binary': The key is left as a string which is encoded as binary. It's default
 %% and backward compatible behaviour. <br />
 %% and backward compatible behaviour. <br />
 %% - `atom': The key is converted to an atom. Results in `badarg' if Key value
 %% - `atom': The key is converted to an atom. Results in `badarg' if Key value

+ 0 - 3
src/jsone_decode.erl

@@ -291,9 +291,6 @@ parse_option([{object_format,F}|T], Opt) when F =:= tuple; F =:= proplist; F =:=
     parse_option(T, Opt?OPT{object_format=F});
     parse_option(T, Opt?OPT{object_format=F});
 parse_option([{allow_ctrl_chars,B}|T], Opt) when is_boolean(B) ->
 parse_option([{allow_ctrl_chars,B}|T], Opt) when is_boolean(B) ->
     parse_option(T, Opt?OPT{allow_ctrl_chars=B});
     parse_option(T, Opt?OPT{allow_ctrl_chars=B});
-parse_option([{labels, K}|T], Opt)
-  when K =:= binary; K =:= atom; K =:= existing_atom; K =:= attempt_atom ->
-    parse_option(T, Opt?OPT{keys = K});
 parse_option([{keys, K}|T], Opt)
 parse_option([{keys, K}|T], Opt)
   when K =:= binary; K =:= atom; K =:= existing_atom; K =:= attempt_atom ->
   when K =:= binary; K =:= atom; K =:= existing_atom; K =:= attempt_atom ->
     parse_option(T, Opt?OPT{keys = K});
     parse_option(T, Opt?OPT{keys = K});

+ 0 - 1
test/jsone_decode_tests.erl

@@ -267,7 +267,6 @@ decode_test_() ->
                        end,
                        end,
               Input = <<"{\"foo\":\"ok\"}">>,
               Input = <<"{\"foo\":\"ok\"}">>,
               ?assertEqual([{<<"foo">>, <<"ok">>}], jsone:decode(Input, KeyOpt(binary))),
               ?assertEqual([{<<"foo">>, <<"ok">>}], jsone:decode(Input, KeyOpt(binary))),
-              ?assertEqual([{foo, <<"ok">>}], jsone:decode(Input, [{labels, atom}, {object_format, proplist}])),
               ?assertEqual([{foo, <<"ok">>}], jsone:decode(Input, KeyOpt(atom))),
               ?assertEqual([{foo, <<"ok">>}], jsone:decode(Input, KeyOpt(atom))),
               ?assertEqual([{foo, <<"ok">>}], jsone:decode(Input, KeyOpt(existing_atom))),
               ?assertEqual([{foo, <<"ok">>}], jsone:decode(Input, KeyOpt(existing_atom))),
               ?assertError(badarg, jsone:decode(<<"{\"@#$%^!\":\"ok\"}">>, KeyOpt(existing_atom))),
               ?assertError(badarg, jsone:decode(<<"{\"@#$%^!\":\"ok\"}">>, KeyOpt(existing_atom))),