Created
November 11, 2014 13:02
-
-
Save dsuch/73bc9b6c5b704fe3aa48 to your computer and use it in GitHub Desktop.
XML/JSON transformations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- 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