whitespace
This commit is contained in:
parent
feaef7380c
commit
4fdd939327
1 changed files with 3 additions and 2 deletions
|
@ -44,6 +44,7 @@ decode(JSON) ->
|
||||||
_:_ -> throw(badarg)
|
_:_ -> throw(badarg)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
%% erlang representation is dicts for objects and lists for arrays. these are pushed
|
%% erlang representation is dicts for objects and lists for arrays. these are pushed
|
||||||
%% onto a stack, the top of which is our current level, deeper levels represent parent
|
%% onto a stack, the top of which is our current level, deeper levels represent parent
|
||||||
%% and grandparent levels in the json structure. keys are also stored on top of the array
|
%% and grandparent levels in the json structure. keys are also stored on top of the array
|
||||||
|
@ -54,7 +55,6 @@ event(start_object, Stack) ->
|
||||||
event(start_array, Stack) ->
|
event(start_array, Stack) ->
|
||||||
[[]] ++ Stack;
|
[[]] ++ Stack;
|
||||||
|
|
||||||
|
|
||||||
event(end_object, [Object, {key, Key}, Parent|Stack]) when is_tuple(Parent) ->
|
event(end_object, [Object, {key, Key}, Parent|Stack]) when is_tuple(Parent) ->
|
||||||
[insert(Key, Object, Parent)] ++ Stack;
|
[insert(Key, Object, Parent)] ++ Stack;
|
||||||
event(end_array, [Array, {key, Key}, Parent|Stack]) when is_tuple(Parent) ->
|
event(end_array, [Array, {key, Key}, Parent|Stack]) when is_tuple(Parent) ->
|
||||||
|
@ -65,6 +65,7 @@ event(end_array, [Array, Parent|Stack]) when is_list(Parent) ->
|
||||||
[[Array] ++ Parent] ++ Stack;
|
[[Array] ++ Parent] ++ Stack;
|
||||||
|
|
||||||
%% special cases for closing the root objects
|
%% special cases for closing the root objects
|
||||||
|
|
||||||
event(end_object, [Object]) ->
|
event(end_object, [Object]) ->
|
||||||
[Object];
|
[Object];
|
||||||
event(end_array, [Array]) ->
|
event(end_array, [Array]) ->
|
||||||
|
@ -85,7 +86,7 @@ event({Type, Value}, [Array|Stack]) when is_list(Array) ->
|
||||||
event(eof, [Stack]) ->
|
event(eof, [Stack]) ->
|
||||||
Stack.
|
Stack.
|
||||||
|
|
||||||
|
|
||||||
%% we're restricting keys to one occurence per object, as the spec implies.
|
%% we're restricting keys to one occurence per object, as the spec implies.
|
||||||
|
|
||||||
insert(Key, Val, Dict) ->
|
insert(Key, Val, Dict) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue