Skip to content

Instantly share code, notes, and snippets.

@nathanborror
Created April 1, 2009 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanborror/88850 to your computer and use it in GitHub Desktop.
Save nathanborror/88850 to your computer and use it in GitHub Desktop.
Build your own JSON
object_list = []
for note in object_list:
obj = {
'id': note.pk,
'note': note.note,
'note.reader_book': {
'id': note.reader_book.id,
'title': note.reader_book.title,
'subtitle': note.reader_book.subtitle,
'authors': ", ".join(["%s" % a.get_full_name for a in note.reader_book.authors.all()]),
'status': note.reader_book.get_status_display(),
'rating': note.reader_book.rating,
'tags': note.reader_book.tags,
'url': 'http://readernaut.com%s' % note.reader_book.get_absolute_url()
}
'url': 'http://readernaut.com%s' % note.get_absolute_url(),
'labels': note.labels(),
'tags': note.tags,
'page_reference': note.page_reference
}
object_list.append(obj)
simplejson.dumps(object_list, sort_keys=True, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment