Created
August 12, 2013 21:38
-
-
Save sukharevd/6215535 to your computer and use it in GitHub Desktop.
Example of work with JSON in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# Example of work with JSON in Python | |
# Requires jsonpickle. To git it in Debian/Ubuntu: | |
# sudo apt-get install python-jsonpickle | |
import jsonpickle | |
__author__ = 'Dmitriy Sukharev' | |
class Book: | |
def __init__(self, isbn, title, authors): | |
self.isbn = isbn | |
self.title = title | |
self.authors = authors | |
book = Book('8789676775433', "Effective Python", ['Smith', 'Jackson']) | |
jsonstr = None | |
jsonstr = jsonpickle.encode(book, False) | |
boook = jsonpickle.decode(jsonstr) | |
print(jsonstr) | |
print(boook) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment