From: Steven Hardy Date: Mon, 9 Jul 2012 16:54:59 +0000 (+0100) Subject: heat API: bugfix to XMLResponseSerializer X-Git-Tag: 2014.1~1624 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=dd94f3eba2d6540a37b8743c8bd15482149b4c05;p=openstack-build%2Fheat-build.git heat API: bugfix to XMLResponseSerializer JSON wrapped in XML responses needs to be serialized with json.dumps not str() or quotes get mangled and json.loads fails to parse the result Change-Id: I65c6ddf0be383e71bf8d05e7293b514269a27213 Signed-off-by: Steven Hardy --- diff --git a/heat/common/wsgi.py b/heat/common/wsgi.py index 07924f93..0118f14f 100644 --- a/heat/common/wsgi.py +++ b/heat/common/wsgi.py @@ -455,7 +455,12 @@ class XMLResponseSerializer(object): subelement = etree.SubElement(element, key) if key in JSON_ONLY_KEYS: if value: - subelement.text = str(value) + # Need to use json.dumps for the JSON inside XML + # otherwise quotes get mangled and json.loads breaks + try: + subelement.text = json.dumps(value) + except: + subelement.text = str(value) else: self.object_to_element(value, subelement) else: