Skip to content

Commit

Permalink
working on puts
Browse files Browse the repository at this point in the history
  • Loading branch information
CloudEdge Solutions committed Sep 14, 2011
1 parent 8ff1788 commit 60851f1
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion change-image/dell/openstack_manager/test/BDD/json.erl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
% Author: RobHirschfeld
%
-module(json).
-export([parse/1, value/2]).
-export([parse/1, value/2, output/1]).
-import(bdd_utils).

-record(json, {list=[], raw=[]}).
Expand Down Expand Up @@ -71,3 +71,22 @@ json(JSON, Key) ->
% entry point
parse(RawJSON) ->
json(#json{raw=RawJSON}, []).

% create json from list
output(List) ->
"{" ++ output_inner(List) ++ "}".

atomize({K, V}) ->
io:format("DEBUG ~p ~p~n", [K, V]),
Value = case V of
[_] -> V;
_ -> output(V)
end,
"\"" ++ K ++ "\":\"" ++ Value ++ "\"".

output_inner([Head | []]) ->
io:format("end"),
atomize(Head);
output_inner([Head | Tail]) ->
atomize(Head) ++ ", " ++ output_inner(Tail).

0 comments on commit 60851f1

Please sign in to comment.