Skip to content

Instantly share code, notes, and snippets.

@sukharevd
Created August 12, 2013 21:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sukharevd/6215535 to your computer and use it in GitHub Desktop.
Save sukharevd/6215535 to your computer and use it in GitHub Desktop.
Example of work with JSON in Python
#!/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