[Opensrf-commits] r1050 - in branches/new-json2: . src/python
src/python/osrf
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Jul 18 18:27:55 EDT 2007
Author: erickson
Date: 2007-07-18 18:27:53 -0400 (Wed, 18 Jul 2007)
New Revision: 1050
Modified:
branches/new-json2/
branches/new-json2/src/python/osrf/json.py
branches/new-json2/src/python/srfsh.py
Log:
Merged revisions 1044-1049 via svnmerge from
svn://svn.open-ils.org/OpenSRF/trunk
........
r1049 | erickson | 2007-07-18 18:27:04 -0400 (Wed, 18 Jul 2007) | 1 line
fixed bug in json encoding of hinted objects and some display bugs
........
Property changes on: branches/new-json2
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-1043
+ /trunk:1-1049
Modified: branches/new-json2/src/python/osrf/json.py
===================================================================
--- branches/new-json2/src/python/osrf/json.py 2007-07-18 22:27:04 UTC (rev 1049)
+++ branches/new-json2/src/python/osrf/json.py 2007-07-18 22:27:53 UTC (rev 1050)
@@ -4,10 +4,21 @@
class osrfJSONNetworkEncoder(simplejson.JSONEncoder):
def default(self, obj):
+
if isinstance(obj, osrfNetworkObject):
+ reg = obj.getRegistry()
+ data = obj.getData()
+
+ # re-encode the object as an array if necessary
+ if reg.wireProtocol == 'array':
+ d = []
+ for k in reg.keys:
+ d.append(data[k])
+ data = d
+
return {
- OSRF_JSON_CLASS_KEY: obj.getRegistry().hint,
- OSRF_JSON_PAYLOAD_KEY: self.default(obj.getData())
+ OSRF_JSON_CLASS_KEY: reg.hint,
+ OSRF_JSON_PAYLOAD_KEY: self.default(data)
}
return obj
@@ -77,9 +88,15 @@
instring = False
inescape = False
done = False
+ eatws = False
for c in json:
+ if eatws: # simpljson adds a pesky after array and object items
+ if c == ' ':
+ continue
+
+ eatws = False
done = False
if (c == '{' or c == '[') and not instring:
t += 1
@@ -94,7 +111,11 @@
if c == ',' and not instring:
r += c + '\n' + __tabs(t)
done = True
+ eatws = True
+ if c == ':' and not instring:
+ eatws = True
+
if c == '"' and not inescape:
instring = not instring
Modified: branches/new-json2/src/python/srfsh.py
===================================================================
--- branches/new-json2/src/python/srfsh.py 2007-07-18 22:27:04 UTC (rev 1049)
+++ branches/new-json2/src/python/srfsh.py 2007-07-18 22:27:53 UTC (rev 1050)
@@ -129,7 +129,7 @@
otp = get_var('SRFSH_OUTPUT')
if otp == 'pretty':
- print osrfDebugNetworkObject(resp.content())
+ print "\n" + osrfDebugNetworkObject(resp.content())
else:
print osrfFormatJSON(osrfObjectToJSON(resp.content()))
More information about the opensrf-commits
mailing list