only pass data to json.dumps/loads

This commit is contained in:
j 2017-01-06 16:37:02 +01:00
parent 6e06214104
commit 6356e9acf2

View file

@ -4,9 +4,9 @@ def loads(*args, **kwargs):
#print('loads', args, kwargs) #print('loads', args, kwargs)
if isinstance(args[0], bytes): if isinstance(args[0], bytes):
args = (args[0].decode('utf-8'),) + args[1:] args = (args[0].decode('utf-8'),) + args[1:]
return json.loads(*args, **kwargs) return json.loads(args[0], **kwargs)
def dumps(*args, **kwargs): def dumps(*args, **kwargs):
#print('dumps', args, kwargs) #print('dumps', args, kwargs)
kwargs['ensure_ascii'] = False kwargs['ensure_ascii'] = False
return json.dumps(*args, **kwargs).encode() return json.dumps(args[0], **kwargs).encode()