def to_json(self): """Provides a simple means to turn the important parsed information into a simple JSON-encoded form. NB this uses the attributes of the object, not the cached DOM object, so information can be altered/added on the fly.""" from compatible_libs import json if json: _j = { 'title': self.title, 'href': self.href, 'description': self.description, 'accept': self.accept, 'accept_multipart': self.accept_multipart, 'mediation': self.mediation, 'treatment': self.treatment, 'collectionPolicy': self.collectionPolicy, 'acceptPackaging': self.acceptPackaging, 'service': self.service, 'categories': self.categories } return json.dumps(_j) else: coll_l.error( "Could not return information about Collection '%s' as JSON" % self.title) return
def to_pretty_json(self): from compatible_libs import json if json: th_l.debug("Attempting to dump %s history items to indented, readable JSON" % len(self)) return json.dumps(self, indent=True) else: th_l.error("Cannot procede with converting the transaction history to JSON")
def to_json(self): from compatible_libs import json if json: th_l.debug("Attempting to dump %s history items to JSON" % len(self)) return json.dumps(self) else: th_l.error( "Cannot procede with converting the transaction history to JSON" )
def to_json(self): """Provides a simple means to turn the important parsed information into a simple JSON-encoded form. NB this uses the attributes of the object, not the cached DOM object, so information can be altered/added on the fly.""" from compatible_libs import json if json: _j = {'title':self.title, 'href':self.href, 'description':self.description, 'accept':self.accept, 'accept_multipart':self.accept_multipart, 'mediation':self.mediation, 'treatment':self.treatment, 'collectionPolicy':self.collectionPolicy, 'acceptPackaging':self.acceptPackaging, 'service':self.service, 'categories':self.categories} return json.dumps(_j) else: coll_l.error("Could not return information about Collection '%s' as JSON" % self.title) return