anchor.diff:  -module(json_utils).
   -author("Tomasz Lichon").
   
  +% Representation of any valid JSON term in erlang
  +-type json_term() :: jiffy:json_value().
  +-export_type([json_term/0]).
  +
   %% API
  --export([encode/1, decode/1]).
  +-export([encode/1, encode/2, decode/1, decode/2]).
   -export([encode_deprecated/1, decode_deprecated/1]).
   -export([map_to_list/1, list_to_map/1]).
   
  
positive.code: 
  %%--------------------------------------------------------------------
  %% @doc
  %% Convenience function that convert an erlang map to JSON, producing
  %% binary result. The output is in UTF8 encoding.
  %% @end
  %%--------------------------------------------------------------------
  -spec encode(maps:map()) -> binary().
  encode(Map) ->
      iolist_to_binary(jiffy:encode(Map)).
  
  %%--------------------------------------------------------------------
  %% @doc
  %% Convenience function that convert JSON binary to an erlang map.
  %% @end
  %%--------------------------------------------------------------------
  -spec decode(binary()) -> maps:map().
  decode(<<"">>) -> maps:new();
  decode(JSON) ->
      try jiffy:decode(JSON, [return_maps]) catch _:_ -> throw(invalid_json) end.
  
  %%--------------------------------------------------------------------
  %% @doc
  %% Convenience function that convert an erlang map to JSON, producing
  %% binary result. The output is in UTF8 encoding.
  %% @end
  %%--------------------------------------------------------------------
  -spec encode_deprecated(term()) -> binary().
  encode_deprecated(Term) ->
      iolist_to_binary(jiffy:encode(list_to_map(Term))).
  
  %%--------------------------------------------------------------------
  %% @doc
  %% Convenience function that convert JSON binary to an erlang map.
  %% @end
  %%--------------------------------------------------------------------
  -spec decode_deprecated(binary()) -> proplists:proplist().
  
negative.code:                  end
      end.
  
  
  %% @private
  -spec is_proplist(term()) -> boolean().
  is_proplist([]) -> true;
  is_proplist([{_,_}|L]) -> is_proplist(L);
  is_proplist(_) -> false.
  