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:
- Number (double precision floating-point format) => Map to int, long, float in Python
- String (double-quoted Unicode with backslash escaping) => Map to str, unicode
- Boolean (true or false) => Map to True, False
- Array (an ordered sequence of values, comma-separated and enclosed in square brackets) => Map to list, tuple
- Object (a collection of key:value pairs, comma-separated and enclosed in curly braces; the key must be a string) => Map to dict
- null => Map to None
More details at:
http://en.wikipedia.org/wiki/JSON, http://www.json.org/, http://docs.python.org/library/json.html
Example:
http://en.wikipedia.org/wiki/JSON, http://www.json.org/, http://docs.python.org/library/json.html
Example:
# 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
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
ReplyDeletevery nice short tutorial. thanks.
ReplyDelete