1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
# You can obtain one at http://mozilla.org/MPL/2.0/.
8
import simplejson as json
10
def json_response(func):
11
""" Translates results of 'func' into a JSON response. """
13
(code, data) = func(*a, **kw)
14
json_data = json.dumps(data)
15
return (code, { 'Content-type': 'application/json',
16
'Content-Length': len(json_data) }, json_data)