We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 99352c8 + 41b4220 commit 606c63dCopy full SHA for 606c63d
src/jsn.erl
@@ -989,7 +989,8 @@ keys_set(Keys, {P}, Value, Empty) when is_list(P) ->
989
keys_set([Key | Rest], Object, Value, Empty)
990
when is_binary(Key), (is_list(Object) orelse is_map(Object)) ->
991
case key_get(Key, Object, jsn__undefined) of
992
- E when Value =:= jsn__delete, (E =:= jsn__undefined orelse E =:= Empty) ->
+ E when Value =:= jsn__delete, Rest /= [],
993
+ (E =:= jsn__undefined orelse E =:= Empty) ->
994
return_if_object(Object, Empty);
995
E when E =:= jsn__undefined; E =:= Empty ->
996
key_set(Key, Object, keys_set(Rest, Empty, Value, Empty));
test/jsn_tests.erl
@@ -295,6 +295,12 @@ delete_test_() ->
295
?_assertEqual(#{}, jsn:delete(Path3, #{})),
296
?_assertEqual([], jsn:delete(<<"foo">>, [{<<"foo">>, <<"bar">>}])),
297
?_assertEqual(#{}, jsn:delete(<<"foo">>, #{<<"foo">> => <<"bar">>})),
298
+ ?_assertEqual(#{}, jsn:delete(<<"foo">>, #{<<"foo">> => #{}})),
299
+ ?_assertEqual(#{}, jsn:delete(<<"foo">>, #{<<"foo">> => []})),
300
+ ?_assertEqual(#{<<"foo">> => #{}},
301
+ jsn:delete(<<"foo.bar">>, #{<<"foo">> => #{<<"bar">> => #{}}})),
302
+ ?_assertEqual(#{<<"foo">> => #{<<"bar">> => #{}}},
303
+ jsn:delete(<<"foo.baz">>, #{<<"foo">> => #{<<"bar">> => #{}}})),
304
?_assertEqual(jsn:new({Path2, [1,2,3]}, [{format, proplist}]),
305
jsn:delete(foo, Object1Plist)),
306
?_assertEqual(jsn:new({Path2, [1,2,3]}, [{format, map}]),
0 commit comments