コード例 #1
0
 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
コード例 #2
0
    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
コード例 #3
0
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)
コード例 #4
0
 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])
コード例 #5
0
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)