我们在下面的代码中将给定的json对象作为python函数的参数。
import json json_string = '{"name":"Rupert", "age": 25, "desig":"developer"}' print type (json_string) def func(strng): a =json.loads(strng) print type(a) for k,v in a.iteritems(): print k,v print dict(a) func(json_string)
<type 'str'> <type 'dict'> desig developer age 25 name Rupert {u'desig': u'developer', u'age': 25, u'name': u'Rupert'}