123456789101112131415161718 |
- from django.shortcuts import HttpResponse
- import simplejson as json
- class ResObject(object):
- def __init__(self, lang='cn'):
- self.lang = lang
- def json(self, code, res={}, extra={}):
- msg_data = {
- 0: 'Success',
- }
- result = {'code': code, 'msg': msg_data[code], 'res': res}
- if extra:
- for k in extra:
- result[k] = extra[k]
- return HttpResponse(json.dumps(result, ensure_ascii=False))
|