anchor.diff:  %%
   %% @end
   field_value_exists_test() ->
  -    Json1 = 
  -	"{"
  -	"\"name\":\"Name1\","
  -	"\"friends\": ["
  -	"{\"name\":\"FriendName1\", \"nickname\":\"NickName1\"},"
  -	"{\"name\":\"FriendName2\", \"nickname\":[\"NickName2\", \"NickName3\"]},"
  -	"{\"name\":\"FriendName3\", \"nickname\":[\"NickName4\", \"NickName5\"]}"
  -	"]"
  -	"}",
  -
  -    Json2 = 
  -	"{"
  -	"\"name\":\"Name1\","
  -	"\"friends\": ["
  -	"{\"name\":\"FriendName2\", \"nickname\":[\"NickName2\", \"NickName3\"]}"
  -	"]"
  -	"}",
  -    ?assertEqual(true, lib_json:field_value_exist(Json1, "friends[1].name", "FriendName2")),
  -
  -    ?assertEqual(false, lib_json:field_value_exist(Json1, "friends[0].name", "FriendName2")),
  -
  -    ?assertEqual(true, lib_json:field_value_exist(Json1, "friends[*].nickname", "NickName1")),
  -
  -    ?assertEqual(true, lib_json:field_value_exist(Json1, "friends[*].nickname", "NickName3")),
  -
  -    ?assertEqual(false, lib_json:field_value_exist(Json1, "friends[*].name", "NickName3")),
  -
  -    ?assertEqual(false, lib_json:field_value_exist(Json2, "friends[*].name", "NickName3")),
  -
  -    ?assertEqual(true, lib_json:field_value_exist(Json2, "friends[*].nickname", "NickName3")),
  -
  -    ?assertEqual(true, lib_json:field_value_exist(Json1, "friends[0]", [{"name", "FriendName1"}, {"nickname", "NickName1"}])),
  -
  -    Result9 = [
  -	       [{"name","FriendName1"},{"nickname","NickName1"}],
  -	       [{"name","FriendName2"},{"nickname",["NickName2","NickName3"]}],
  -	       [{"name","FriendName3"},{"nickname",["NickName4","NickName5"]}]	       
  -	      ],
  -    ?assertEqual(true, lib_json:field_value_exist(Json1, "friends", Result9)).
  +    ?assertEqual(true, lib_json:field_value_exist(?JSON1, "friend[1].name", "FriendName2")),
  +    ?assertEqual(false, lib_json:field_value_exist(?JSON1, "friend[0].name", "FriendName2")),
  +    ?assertEqual(true, lib_json:field_value_exist(?JSON1, "friend[*].nickname", "NickName1")),
  +    ?assertEqual(true, lib_json:field_value_exist(?JSON1, "friend[*].nickname", "NickName3")),
  +    ?assertEqual(false, lib_json:field_value_exist(?JSON1, "friend[*].name", "NickName3")),
  +    ?assertEqual(false, lib_json:field_value_exist(?JSON2, "friend[*].name", "NickName3")),
  +    ?assertEqual(true, lib_json:field_value_exist(?JSON2, "friend.nickname", "NickName3")),
  +    ?assertEqual(true, lib_json:field_value_exist(
  +			 ?JSON1, "friend[0]", 
  +			 [{"name", "FriendName1"}, {"nickname", "NickName1"}]
  +			)),
  +    ?assertEqual(true, lib_json:field_value_exist(?JSON1, "friend", ?GET_FIELD_RESULT1)).
   
   %% @doc
   %% Function: encode_test/0
  
positive.code: 	     {friend, {{name, "FriendName2"}, {nickname, ["NickName2", "NickName3"]}}}
  	    },
  
      Result1 = 
  	[$\{,[$\", <<"name">>,$\"],$:,[$\",<<"Name1">>,$\"],$,,[$\",<<"friends">>,$\"],$:,[$[,[${,[$\",<<"name">>,$\"],$:,[$\",<<"FriendName1">>,$\"],$,,[$\",<<"nickname">>,$\"],$:,[$\",<<"NickName1">>,$\"],$}],$,,[${,[$\",<<"name">>,$\"],$:,[$\",<<"FriendName2">>,$\"],$,,[$\",<<"nickname">>,$\"],$:,[$[,[$\",<<"NickName2">>,$\"],$,,[$\",<<"NickName3">>,$\"],$]],$}],$]],$}],
  
      ?assertEqual(Result1, lib_json:encode(Json1)),
  
  
      Result2 = 
  	"{"
  	"\"name\":\"Name1\","
  	  "\"friend\": ["
  	  "{\"name\":\"FriendName1\", \"nickname\":\"NickName1\"},"
  	  "{\"name\":\"FriendName2\", \"nickname\":[\"NickName2\", \"NickName3\"]}"
  	  "]"
  	  "}",
  	  ?assertEqual(Result2, lib_json:encode({non_mochi, Json2})),
  	  
      Result3 = 
  	"{"
  	  "\"name\":\"Name1\","
  	  "\"friends\": ["
  	  "{\"name\":\"FriendName1\", \"nickname\":\"NickName1\"},"
  	  "{\"name\":\"FriendName2\", \"nickname\":[\"NickName2\", \"NickName3\"]}"
  	  "]"
  	  "}",
  	  ?assertEqual(Result3, lib_json:encode({non_mochi, Json3})).
  
  
  %% @doc
  
negative.code: -include("json.hrl").
  -export([]).
  
  -define(JSON1, 
  	"{"
  	"\"name\":\"Name1\","
  	"\"friend\": ["
  	"{\"name\":\"FriendName1\", \"nickname\":\"NickName1\"},"
  	"{\"name\":\"FriendName2\", \"nickname\":[\"NickName2\", \"NickName3\"]},"
  	"{\"name\":\"FriendName3\", \"nickname\":[\"NickName4\", \"NickName5\"]}"
  	"]"
  	"}").
  
  -define(JSON2, 
  	"{"
  	"\"name\":\"Name1\","
  	"\"friend\": {\"name\":\"FriendName2\", \"nickname\":[\"NickName2\", \"NickName3\"]}"
  	"}").
  
  -define(GET_FIELD_RESULT1, 
  	[[{"name","FriendName1"},{"nickname","NickName1"}],
  	 [{"name","FriendName2"},{"nickname",["NickName2","NickName3"]}],
  	 [{"name","FriendName3"},{"nickname",["NickName4","NickName5"]}]
  	]).
  
  -define(ENCODE_RESULT1, 
  	[$\{,[$\", <<"name">>,$\"],$:,[$\",<<"Name1">>,$\"],$,,[$\",<<"friend">>,$\"],$:,[$[,
  [${,[$\",<<"name">>,$\"],$:,[$\",<<"FriendName1">>,$\"],$,,[$\",<<"nickname">>,$\"],$:,[$\",<<"NickName1">>,$\"],$}],$,,
  [${,[$\",<<"name">>,$\"],$:,[$\",<<"FriendName2">>,$\"],$,,[$\",<<"nickname">>,$\"],$:,[$[,[$\",<<"NickName2">>,$\"],$,,[$\",<<"NickName3">>,$\"],$]],$}],$,,
  [${,[$\",<<"name">>,$\"],$:,[$\",<<"FriendName3">>,$\"],$,,[$\",<<"nickname">>,$\"],$:,[$[,[$\",<<"NickName4">>,$\"],$,,[$\",<<"NickName5">>,$\"],$]],$}]
  ,$]],$}]).
  
  -define(DECODE_RESULT1,
  	[{"name","Name1"},
  	 {"friend",
  	  [
  	   [{"name","FriendName1"},{"nickname","NickName1"}],
  	   [{"name","FriendName2"},{"nickname",["NickName2","NickName3"]}],
  	   [{"name","FriendName3"},{"nickname",["NickName4","NickName5"]}]
  	  ]
  	 }
  	]).
  
  %% @doc
  %% Function: get_field_test/0
  %% Purpose: Test the json_lib:get_field/2 by attempting to get various fields 
  %%          from string json objects
  %% Returns: ok | {error, term()}
  %%
  %% @end
  get_field_test() ->
      ?assertEqual("Name1", lib_json:get_field(?JSON1, "name")),
  
  
      ?assertEqual(?GET_FIELD_RESULT1, lib_json:get_field(?JSON1, "friend")),
  
      Result3 = [{"name", "FriendName1"}, {"nickname", "NickName1"}],
      ?assertEqual(Result3, lib_json:get_field(?JSON1, "friend[0]")),
  
      ?assertEqual("FriendName1", lib_json:get_field(?JSON1, "friend[0].name")),
  
      ?assertEqual("NickName1", lib_json:get_field(?JSON1, "friend[0].nickname")),
  
      Result6 = ["NickName2", "NickName3"],
      ?assertEqual(Result6, lib_json:get_field(?JSON1, "friend[1].nickname")),
  
      ?assertEqual("NickName2", lib_json:get_field(?JSON1, "friend[1].nickname[0]")),
  
      ?assertEqual(undefined, lib_json:get_field(?JSON1, "friend[0].nick")),
  
      Result9 = [{"name","FriendName2"}, {"nickname",["NickName2","NickName3"]}],
      ?assertEqual(Result9, lib_json:get_field(?JSON2, "friend")).
  
  %% @doc
  %% Function: get_field_value_test/0
  %% Purpose: Test the json_lib:get_field_value/2 by attempting to get various fields 
  %%          from string json objects
  %% Returns: ok | {error, term()}
  %%
  %% @end
  get_field_value_test() ->
      ?assertEqual("FriendName2", lib_json:get_field_value(?JSON1, "friend[1].name", "FriendName2")),
      ?assertEqual(false, lib_json:get_field_value(?JSON1, "friend[0].name", "FriendName2")),
      ?assertEqual("NickName1", lib_json:get_field_value(?JSON1, "friend[*].nickname", "NickName1")),
      ?assertEqual("NickName3", lib_json:get_field_value(?JSON1, "friend[*].nickname", "NickName3")),
      ?assertEqual(false, lib_json:get_field_value(?JSON1, "friend[*].name", "NickName3")),
      ?assertEqual(false, lib_json:get_field_value(?JSON2, "friend[*].name", "NickName3")),
      ?assertEqual("NickName3", lib_json:get_field_value(?JSON2, "friend.nickname", "NickName3")),
  
      Result8 = [{"name", "FriendName1"}, {"nickname", "NickName1"}],
      ?assertEqual(Result8, lib_json:get_field_value(?JSON1, "friend[0]", Result8)),
  
      ?assertEqual(?GET_FIELD_RESULT1, lib_json:get_field_value(?JSON1, "friend", ?GET_FIELD_RESULT1)),
  
  
      %% This call will produce an error. Added here as an example of how 
      %% lib_json:get_field_value/3 NOT should be used. The second argument is not
      %% allowed to end with [*]
      %% See lib_json:get_field_value/3 for details of how to use the function
      Try = try lib_json:get_field_value(?JSON1, "friend[*]", "") of
  	      _ -> will_not_happen
  	  catch
  	      _:_ -> error
  	  end,    
      ?assertEqual(error, Try).
  
  