tags:

views:

96

answers:

3

Possible Duplicate:
Easy JSON encoding with Python

I want to get a record from database and built it in to json. I know we can do it with json_encode when using PHP. But how can we do it in Python

+3  A: 
# Python 2.6+
import json
result = json.dumps(value)
or
# Python 2.6+
import json
json.dump(value, out_file)

Got if from google first result. http://www.php2python.com/wiki/function.json-encode/

Please do your research before asking simple, searchable questions!

etbal
then the question may be, what json implementation is most stable/featured/available on Python3. Not asking, but isn't that style of hints is welcome?
mhambra
A: 

You can use the json library, just

import json
joaquin
+2  A: 

There are several json implementations for Python. I like simplejson because it's, well, simple.

Bill Gribble