How to use the pydal.helpers.serializers.serializers.json function in pydal

To help you get started, we’ve selected a few pydal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github web2py / pydal / pydal / adapters / google_adapters.py View on Github external
def represent(self, obj, fieldtype, tablename=None):
        if isinstance(obj, ndb.Key):
            return obj
        elif fieldtype == 'id' and tablename:
            if isinstance(obj, list):
                return [self.represent(item,fieldtype,tablename) for item in obj]
            elif obj is None:
                return None
            else:
                return ndb.Key(tablename, long(obj))
        elif fieldtype == "json":
            return serializers.json(obj)
        elif isinstance(obj, (Expression, Field)):
            raise SyntaxError("non supported on GAE")
        elif isinstance(fieldtype, gae.Property):
            return obj
        elif fieldtype.startswith('list:') and not isinstance(obj, list):
            if fieldtype=='list:string': return str(obj)
            else: return long(obj)
        else:
            obj = NoSQLAdapter.represent(self, obj, fieldtype)
            return obj
github web2py / pydal / pydal / adapters / couchdb.py View on Github external
def represent(self, obj, fieldtype):
        value = NoSQLAdapter.represent(self, obj, fieldtype)
        if fieldtype == 'id':
            return repr(str(long(value)))
        elif fieldtype in ('date', 'time', 'datetime', 'boolean'):
            return serializers.json(value)
        return repr(not isinstance(value, unicode) and value
                    or value and value.encode('utf8'))
github web2py / pydal / pydal / representers / base.py View on Github external
def _json(self, value):
        return serializers.json(value)
github web2py / pydal / pydal / objects.py View on Github external
):
        """
        serializes the row to a JSON object
        kwargs are passed to .as_dict method
        only "object" mode supported

        `serialize = False` used by Rows.as_json

        TODO: return array mode with query column order

        mode and colnames are not implemented
        """

        item = self.as_dict(**kwargs)
        if serialize:
            return serializers.json(item)
        else:
            return item
github web2py / pydal / pydal / representers / couchdb.py View on Github external
def _datetime(self, value):
        return serializers.json(value)
github web2py / pydal / pydal / representers / google.py View on Github external
def _json(self, value):
        return serializers.json(value)

pydal

pyDAL is a Database Abstraction Layer. It generates queries for SQlite, PotsgreSQL, MySQL, and other backends. It was originally part of the web2py frameworks but it is now an independent project. Example: db.define_table("thing",Field("name")) and db.thing.insert(name="Pizza")

BSD-3-Clause
Latest version published 11 days ago

Package Health Score

78 / 100
Full package analysis