Ejemplo n.º 1
0
 def to_json(self, resource):
     '''
     Builds JSON for resource according to fields attribute
     '''
     if not resource: 
         return
     elif is_relatedmanager(resource) or is_manyrelatedmanager(resource):
         return [self.to_json( i ) for i in resource.all()]
     return self.__fields_to_json( resource )
Ejemplo n.º 2
0
 def __serialize(self, x):
     '''
     Converts to JSON-serializable object
     '''
     if is_serializable(x):
         return x
     elif is_geo_value(x):
         return json.loads(x.geojson)
     elif is_relatedmanager(x) or is_manyrelatedmanager(x):
         return [unicode(i) for i in x.all()]
     return unicode(x)