From 86fa951ba99a04edf6a41b04751a1ad679dc2d36 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Fri, 24 Dec 2010 04:35:53 +0000 Subject: Apply roundtripping fixes from SVN r1052432 to Python and Javascript scripts. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1052445 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/wsgi/jsonutil.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'sca-cpp/trunk/modules/wsgi/jsonutil.py') diff --git a/sca-cpp/trunk/modules/wsgi/jsonutil.py b/sca-cpp/trunk/modules/wsgi/jsonutil.py index f69559de54..ad8f5fcc6b 100644 --- a/sca-cpp/trunk/modules/wsgi/jsonutil.py +++ b/sca-cpp/trunk/modules/wsgi/jsonutil.py @@ -64,7 +64,14 @@ def jsValToValue(jsv): if isinstance(jsv, basestring): return str(jsv) return jsv - + +# Return true if a list of strings contains a JSON document +def isJSON(l): + if isNil(l): + return False + s = car(l)[0:1] + return s == "[" or s == "{" + # Convert a list of strings representing a JSON document to a list of values def readJSON(l): s = StringIO() @@ -108,7 +115,10 @@ def valuesToJSProperties(o, l): # Convert a list of values to a list of strings representing a JSON document def writeJSON(l): - jsv = valuesToJSProperties({}, l) + if isJSArray(l): + jsv = valuesToJSElements(list(range(0, len(l))), l, 0) + else: + jsv = valuesToJSProperties({}, l) s = json.dumps(jsv, separators=(',',':')) return (s,) -- cgit v1.2.3