Profile

Click to view full profile
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time. Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more...

Friday, March 25, 2011

How to use JSON in python

JSON stands for JavaScript Object Notation. It is a light-weight text format that usually used it for data interchange (alternative choice to XML based). We can use it in  RESTful services.
to
Now, it just a example how encrypt and decrypt JSON in Python. The most important in JSON is the property key must be string only.

The followings are available data type in JSON:

# Python can use json from standard library
import json
# Create object in python
ob = {'name':'Json','email':['x@a.com','x@b.com']}
# Convert python object into json string format
jstring = json.dumps(ob)
print jstring
# Load python object from json string
jobject = json.loads(jstring)
print jobject

2 comments:

  1. json is a very interesting language to be used. very good tutorial and can hopefully help me in building json in the application that I created for this lecture. thank you

    ReplyDelete
  2. very nice short tutorial. thanks.

    ReplyDelete