ricardokirkner/collection-json.python — pull request #8 by ievans3024 (2014-11-05 01:33:06+00:00)
Title: + added Collection.__str__

It should be easy to turn this object into a string, for packaging data assembled in python by a server to be sent in a response to a client.

Prior to this commit, this was done like so:

import collection_json
import json

collection = collection_json.Collection(href='/api/')
string_form = json.dumps(collection.to_dict())

It's kind of a waste to force a developer to import json into their code when it is already imported into this module. With this patch, the need to import json is eliminated, and Collections can simply be passed to `str()` like so:

import collection_json

collection = collection_json.Collection(href='/api/')
string_form = str(collection)