anchor.diff:      end.
   
   
  -%% @private
   -spec merge([json_term()]) -> json_term().
   merge(JsonTerms) ->
       lists:foldl(fun
  -        (Json, ParentJson) when is_map(Json) andalso is_map(ParentJson) ->
  -            ChildKeys = maps:keys(Json),
  -            ParentKeys = maps:keys(ParentJson),
  -            ChildOnlyKey = ChildKeys -- ParentKeys,
  -            CommonKeys = ChildKeys -- ChildOnlyKey,
  -
  -            ResultingJson = maps:merge(
  -                ParentJson,
  -                maps:with(ChildOnlyKey, Json)
  -            ),
  -
  -            lists:foldl(fun(Key, Acc) ->
  -                ChildValue = maps:get(Key, Json),
  -                ParentValue = maps:get(Key, ParentJson),
  -                Acc#{Key => merge([ParentValue, ChildValue])}
  -            end, ResultingJson, CommonKeys);
  +        (ChildJson, ParentJson) when is_map(ChildJson) andalso is_map(ParentJson) ->
  +
  +            maps:fold(fun(ChildKey, ChildValue, Acc) ->
  +                case maps:find(ChildKey, ParentJson) of
  +                    {ok, ParentValue} ->
  +                        Acc#{ChildKey => merge([ParentValue, ChildValue])};
  +                    error ->
  +                        Acc#{ChildKey => ChildValue}
  +                end
  +            end, ParentJson, ChildJson);
   
           (Json, _ParentJson) ->
               Json
  
positive.code:                             ++ [null || _ <- lists:seq(Length + 1, Index - 1)]
                              ++ [insert(undefined, JsonToInsert, Rest)];
                          false ->
                              setnth(
                                  Index, Json,
                                  insert(lists:nth(Index, Json), JsonToInsert, Rest)
                              )
                      end
              end;
  
negative.code: % binaries in maps intended for JSON serialization.
  -type json_map() :: #{binary() => json_term()}.
  
  % List of binaries pointing to sub-json of a json, e.g
  % [<<"attr1">>, <<"[2]">>] points to element <<"a">> in
  % #{<<"attr1">> => [1, null, <<"a">>], <<"attr2">> => <<"val2">>}
  -type filter() :: [binary()].
  
  -export_type([json_term/0, json_map/0, filter/0]).
  