Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

working on puts

  • Loading branch information...
commit 60851f1c8c945943caf49bcefaf58bf71bc2c9be 1 parent 8ff1788
CloudEdge Solutions authored
Showing with 20 additions and 1 deletion.
  1. +20 −1 change-image/dell/openstack_manager/test/BDD/json.erl
21 change-image/dell/openstack_manager/test/BDD/json.erl
View
@@ -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=[]}).
@@ -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).
+
Please sign in to comment.
Something went wrong with that request. Please try again.