Ejemplo n.º 1
0
 def morph_response_body(self, body_string):
     # The root XML element always becomes a dictionary with a single
     # field, which has the same key as the elements name.
     result = {}
     try:
         root_element = etree.XML(body_string)
     except etree.XMLSyntaxError:
         raise exceptions.ResponseFormatError()
     root_name = normalize_tag(root_element)
     root_value, links = root_element_to_json(root_name, root_element)
     result = {root_name: root_value}
     if links:
         result['links'] = links
     modify_response_types(result, TYPE_MAP)
     return result
Ejemplo n.º 2
0
 def morph_response_body(self, body_string):
     try:
         return json.loads(body_string)
     except ValueError:
         raise exceptions.ResponseFormatError()