From 4fdd9393270288f2c1ba70b534f4242a3319a4d0 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Tue, 25 May 2010 21:52:56 -0700 Subject: [PATCH] whitespace --- examples/jsx_parser.erl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/jsx_parser.erl b/examples/jsx_parser.erl index e6d5b40..836a054 100644 --- a/examples/jsx_parser.erl +++ b/examples/jsx_parser.erl @@ -44,6 +44,7 @@ decode(JSON) -> _:_ -> throw(badarg) end. + %% 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 %% 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) -> [[]] ++ Stack; - event(end_object, [Object, {key, Key}, Parent|Stack]) when is_tuple(Parent) -> [insert(Key, Object, Parent)] ++ Stack; 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; %% special cases for closing the root objects + event(end_object, [Object]) -> [Object]; event(end_array, [Array]) -> @@ -85,7 +86,7 @@ event({Type, Value}, [Array|Stack]) when is_list(Array) -> event(eof, [Stack]) -> Stack. - + %% we're restricting keys to one occurence per object, as the spec implies. insert(Key, Val, Dict) ->