Skip to content

Instantly share code, notes, and snippets.

@dsuch
Created November 11, 2014 13:02
Show Gist options
  • Select an option

  • Save dsuch/73bc9b6c5b704fe3aa48 to your computer and use it in GitHub Desktop.

Select an option

Save dsuch/73bc9b6c5b704fe3aa48 to your computer and use it in GitHub Desktop.
XML/JSON transformations
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# hutools
from huTools.structured import dict2xml
# xmltodict
from xmltodict import parse as parse_xml
# Zato
from zato.server.service import Service
class MyConverter(Service):
def handle(self):
# This gives you a dictionary suitable for use with JSON connections
d = parse_xml(self.request.raw_request)
# Here we load the response from
response = {'foo': 'bar'}
self.response.payload = dict2xml(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment