@@ -130,9 +130,9 @@ try_encode(JsonValue, Options) ->
130
130
end .
131
131
132
132
133
- % %--------------------------------------------------------------------------------
134
133
% % Internal Functions
135
- % %--------------------------------------------------------------------------------
134
+
135
+
136
136
-spec create_decoders ([decode_option ()], json :decoders ()) -> json :decoders ().
137
137
create_decoders ([], Acc ) ->
138
138
Acc ;
@@ -148,7 +148,7 @@ create_decoders([{keys, attempt_atom} | Options], Acc) ->
148
148
end ,
149
149
create_decoders (Options , Acc #{object_push => ObjectPush });
150
150
create_decoders (Options , Acc ) ->
151
- % % 不明なオプションがあった
151
+ % % 不明なオプションが指定されていたらエラーにする
152
152
erlang :error (badarg , [Options , Acc ]).
153
153
154
154
@@ -177,6 +177,7 @@ build_encode_options([undefined_as_null | Options], Acc) ->
177
177
build_encode_options ([{float_format , Format } | Options ], Acc ) ->
178
178
build_encode_options (Options , Acc # encode_options {float_format = Format });
179
179
build_encode_options (Options , Acc ) ->
180
+ % % 不明なオプションが指定されていたらエラーにする
180
181
erlang :error (badarg , [Options , Acc ]).
181
182
182
183
@@ -212,8 +213,13 @@ encode(Value, Encoder, _Options) ->
212
213
213
214
214
215
decode_test () ->
216
+ % % Basic decoding.
215
217
? assertEqual (#{<<" foo" >> => 1 }, decode (~ ' {"foo": 1}' )),
218
+
219
+ % % `attempt_atom` option.
216
220
? assertEqual (#{foo => 1 }, decode (~ ' {"foo": 1}' , [{keys , attempt_atom }])),
221
+ ? assertEqual (#{<<" no_existing_atom" >> => 1 }, decode (~ ' {"no_existing_atom": 1}' , [{keys , attempt_atom }])),
222
+
217
223
ok .
218
224
219
225
0 commit comments