[rhmessaging-commits] rhmessaging commits: r3475 - mgmt/trunk/cumin/python/cumin.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Sat Jul 4 14:14:27 EDT 2009
Author: eallen
Date: 2009-07-04 14:14:27 -0400 (Sat, 04 Jul 2009)
New Revision: 3475
Modified:
mgmt/trunk/cumin/python/cumin/OpenFlashChart.py
Log:
Use cjson or json if present.
Modified: mgmt/trunk/cumin/python/cumin/OpenFlashChart.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/OpenFlashChart.py 2009-07-04 18:12:38 UTC (rev 3474)
+++ mgmt/trunk/cumin/python/cumin/OpenFlashChart.py 2009-07-04 18:14:27 UTC (rev 3475)
@@ -10,7 +10,18 @@
# Author: Eugene Kin Chee Yip
# Date: 14 June 2009
-# Modified to not use json or cjson by Ernie
+# Modified to not require cjson or json by Ernie
+CJSON = False
+JJSON = False
+try:
+ import cjson
+ CJSON = True
+except ImportError:
+ try:
+ import json
+ JJSON = True
+ except ImportError:
+ pass
import copy
class Chart(dict):
@@ -66,9 +77,13 @@
# Encode the chart attributes as JSON
def create(self):
attributes = copy.copy(self)
- # the json parser in open flash chart .swf requires double quotes
- # this assumes we don't have any single quotes in the line names
- return str(attributes).replace("'", '"')
+ if CJSON:
+ return cjson.encode(attributes)
+ elif JJSON:
+ return json.dumps(attributes)
+ else:
+ return str(attributes)
+
class Element(Chart):
pass
\ No newline at end of file
More information about the rhmessaging-commits
mailing list