def to_json(self): """ Returns a JSON-friendly python dictionary. Structure:: created: datetime, operations: list of operations, versions: list of versions, payload: dictionary with lists of objects mapped to model names """ encoded = super(PullMessage, self).to_json() encoded["created"] = encode(types.DateTime())(self.created) encoded["operations"] = map(encode_dict(Operation), imap(properties_dict, self.operations)) encoded["versions"] = map(encode_dict(Version), imap(properties_dict, self.versions)) return encoded
def to_json(self): """ Returns a JSON-friendly python dictionary. Structure:: created: datetime, operations: list of operations, versions: list of versions, payload: dictionary with lists of objects mapped to model names """ encoded = super(PullMessage, self).to_json() encoded['created'] = encode(types.DateTime())(self.created) encoded['operations'] = map(encode_dict(Operation), imap(properties_dict, self.operations)) encoded['versions'] = map(encode_dict(Version), imap(properties_dict, self.versions)) return encoded
def to_json(self): "Returns a JSON-friendly python dictionary." encoded = super(PullRequestMessage, self).to_json() encoded['operations'] = map(encode_dict(Operation), imap(properties_dict, self.operations)) encoded['latest_version_id'] = encode(types.Integer())( self.latest_version_id) return encoded
def to_json(self): "Returns a JSON-friendly python dictionary." encoded = {} encoded['payload'] = {} for k, objects in self.payload.iteritems(): model = synched_models.model_names.get(k, null_model).model if model is not None: encoded['payload'][k] = map(encode_dict(model), imap(method('to_dict'), objects)) return encoded
def to_json(self) -> Dict[str, Any]: """Returns a JSON-friendly python dictionary.""" encoded: Dict[str, Any] = {'payload': {}} for k, objects in list(self.payload.items()): model = synched_models.model_names.get(k, null_model).model if model is not None: encoded['payload'][k] = list( map(encode_dict(model), list(map(method('to_dict'), objects)))) return encoded
def to_json(self): """ Returns a JSON-friendly python dictionary. Structure:: created: datetime, node_id: node primary key or null, key: a string generated from the secret and part of the message, latest_version_id: number or null, operations: list of operations, payload: dictionay with lists of objects mapped to model names """ encoded = super(PushMessage, self).to_json() encoded['created'] = encode(types.DateTime())(self.created) encoded['node_id'] = encode(types.Integer())(self.node_id) encoded['key'] = encode(types.String())(self.key) encoded['latest_version_id'] = encode(types.Integer())( self.latest_version_id) encoded['operations'] = map(encode_dict(Operation), imap(properties_dict, self.operations)) return encoded
def to_json(self): encoded = {} encoded['node'] = None if self.node is not None: encoded['node'] = encode_dict(Node)(properties_dict(self.node)) return encoded
def to_json(self): "Returns a JSON-friendly python dictionary." encoded = super(PullRequestMessage, self).to_json() encoded["operations"] = map(encode_dict(Operation), imap(properties_dict, self.operations)) encoded["latest_version_id"] = encode(types.Integer())(self.latest_version_id) return encoded