Skip to content

Instantly share code, notes, and snippets.

@sakal
Created March 27, 2012 16:51
Show Gist options
  • Save sakal/2217857 to your computer and use it in GitHub Desktop.
Save sakal/2217857 to your computer and use it in GitHub Desktop.
>>> t =json.dumps({'k1':1, 'k2':[1,2,3], 'k3':'blah', 'k4': None})
>>> t
'{"k3": "blah", "k2": [1, 2, 3], "k1": 1, "k4": null}'
>>> json.loads(t)
{u'k3': u'blah', u'k2': [1, 2, 3], u'k1': 1, u'k4': None}
>>> con.hmset("test:hm", {'t':t})
True
>>> v=con.hmget("test:hm", 't')
>>> v
['{"k3": "blah", "k2": [1, 2, 3], "k1": 1, "k4": null}']
>>> json.loads(v[0])
{u'k3': u'blah', u'k2': [1, 2, 3], u'k1': 1, u'k4': None}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment