summaryrefslogtreecommitdiff
path: root/src/mochiweb/mochijson2.erl
diff options
context:
space:
mode:
authorChristopher Lenz <cmlenz@apache.org>2008-08-31 09:43:41 +0000
committerChristopher Lenz <cmlenz@apache.org>2008-08-31 09:43:41 +0000
commit15a175144d83d6177e9bbb923a7f7157e5ea8917 (patch)
tree92b7becc9610c46f87ddf7ab4c313642b007c4aa /src/mochiweb/mochijson2.erl
parentac4075a7987dc43aadeb18a94e07f090d1b77546 (diff)
Merged json_term_changes branch back into trunk.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@690668 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/mochiweb/mochijson2.erl')
-rw-r--r--src/mochiweb/mochijson2.erl14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mochiweb/mochijson2.erl b/src/mochiweb/mochijson2.erl
index 592b4790..6fa7499c 100644
--- a/src/mochiweb/mochijson2.erl
+++ b/src/mochiweb/mochijson2.erl
@@ -104,7 +104,7 @@ json_encode(S, State) when is_binary(S); is_atom(S) ->
json_encode_string(S, State);
json_encode(Array, State) when is_list(Array) ->
json_encode_array(Array, State);
-json_encode({struct, Props}, State) when is_list(Props) ->
+json_encode({Props}, State) when is_list(Props) ->
json_encode_proplist(Props, State);
json_encode(Bad, #encoder{handler=null}) ->
exit({json_encode, {bad_term, Bad}});
@@ -220,7 +220,7 @@ decode_object(B, S) ->
decode_object(B, S=#decoder{state=key}, Acc) ->
case tokenize(B, S) of
{end_object, S1} ->
- V = make_object({struct, lists:reverse(Acc)}, S1),
+ V = make_object({lists:reverse(Acc)}, S1),
{V, S1#decoder{state=null}};
{{const, K}, S1} ->
{colon, S2} = tokenize(B, S1),
@@ -230,7 +230,7 @@ decode_object(B, S=#decoder{state=key}, Acc) ->
decode_object(B, S=#decoder{state=comma}, Acc) ->
case tokenize(B, S) of
{end_object, S1} ->
- V = make_object({struct, lists:reverse(Acc)}, S1),
+ V = make_object({lists:reverse(Acc)}, S1),
{V, S1#decoder{state=null}};
{comma, S1} ->
decode_object(B, S1#decoder{state=key}, Acc)
@@ -396,9 +396,9 @@ tokenize(B, S=#decoder{offset=O}) ->
%% Create an object from a list of Key/Value pairs.
obj_new() ->
- {struct, []}.
+ {[]}.
-is_obj({struct, Props}) ->
+is_obj({Props}) ->
F = fun ({K, _}) when is_binary(K) ->
true;
(_) ->
@@ -407,7 +407,7 @@ is_obj({struct, Props}) ->
lists:all(F, Props).
obj_from_list(Props) ->
- Obj = {struct, Props},
+ Obj = {Props},
case is_obj(Obj) of
true -> Obj;
false -> exit({json_bad_object, Obj})
@@ -418,7 +418,7 @@ obj_from_list(Props) ->
%% compare unequal as erlang terms, so we need to carefully recurse
%% through aggregates (tuples and objects).
-equiv({struct, Props1}, {struct, Props2}) ->
+equiv({Props1}, {Props2}) ->
equiv_object(Props1, Props2);
equiv(L1, L2) when is_list(L1), is_list(L2) ->
equiv_list(L1, L2);