Personal tools
You are here: Home Downloads Tutorials Python Json
nrcfoss logo aukbc cdac iit mumbai iit madras ow2 iosn flosscc
india.gov.in
 

Json

You may heard the term many times !!! A subset of JavaScript syntax (ECMA 262) Used as a lightweight data interchange format.

JSON  :   Java Script Object Notation

 

json.dumps  and json.load    encoding and decoding values...

 

pretty encoding .. compact encoding

 

 

Performs the following transitions  in decoding  by default. ...

 

 

 

JSON Python
object dict
array list
string unicode
number (int) int, long
number (real) float
true True
false False
null None

 

 

Extensible JSON encoder for Python data structures.

Supports the following objects and types by default:

Python JSON
dict object
list, tuple array
str, unicode string
int, long, float number
True true
False false
None null

 

How You can make   JSON  requests with python

 

   suppose you wanted to add some data( piece of information will do some action in computation)    through an  HTTP POST.

 

To send the data to the webserver you can encode data  inthe URL or in the message body by ( GET  or POST  resply..)

 

 

see here an example ...

 

import  urllib2

import  json

 

data = {'first_name': 'Devin','last_name':'Fee','url':'http://devinfee.com/blog'}

 

data_json = json.dumps(data)

host = "http://devinfee.com/example/json/create"

req = urllib2.Request(host, data_json, {'content-type': 'application/json'})

 

response_stream = urllib2.urlopen(req)

response = response_stream.read()

 

 

The response will contain the ID or list of IDs for the newly

created database objects on the backend.

Document Actions