diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-24 04:35:53 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-24 04:35:53 +0000 |
commit | 86fa951ba99a04edf6a41b04751a1ad679dc2d36 (patch) | |
tree | c366d8560cf95210f8c2400fdec76652142950f9 /sca-cpp/trunk/modules/wsgi/jsonutil.py | |
parent | 150feb74a6f2897d860be360cedf641e004f5ca8 (diff) |
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
Diffstat (limited to '')
-rw-r--r-- | sca-cpp/trunk/modules/wsgi/jsonutil.py | 14 |
1 files changed, 12 insertions, 2 deletions
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,) |