def output(self, value): lst = [] field = self.context.value_type for v in value: converted = IJSONGenerator(field).output(v) if converted is not None: lst.append(converted) return lst
def output(self, value): cd = {} for name, field in getFieldsInOrder(self.context.schema): if value is None: return value cd[name] = IJSONGenerator(field).output(field.get(value)) return cd
def deserialize_from_dict(container, schema, instance): for key, value in container.iteritems(): field = schema[key] value = IJSONGenerator(field).input(value) field.set(instance, value)
def input(self, item): field = self.context.value_type if item is None: return set() return set( [IJSONGenerator(field).input(sub_item) for sub_item in item])
def serialize_to_tree(container, schema, instance): for name, field in getFieldsInOrder(schema): value = field.get(instance) if not field.required and value is None: continue container[name] = IJSONGenerator(field).output(value)