class_docstr: Represent the PostgreSQL JSON type.
  
  :class:`_postgresql.JSON` is used automatically whenever the base
  :class:`_types.JSON` datatype is used against a PostgreSQL backend,
  however base :class:`_types.JSON` datatype does not provide Python
  accessors for PostgreSQL-specific comparison methods such as
  :meth:`_postgresql.JSON.Comparator.astext`; additionally, to use
  PostgreSQL ``JSONB``, the :class:`_postgresql.JSONB` datatype should
  be used explicitly.
  
  .. seealso::
  
      :class:`_types.JSON` - main documentation for the generic
      cross-platform JSON datatype.
  
  The operators provided by the PostgreSQL version of :class:`_types.JSON`
  include:
  
  * Index operations (the ``->`` operator)::
  
      data_table.c.data['some key']
  
      data_table.c.data[5]
  
  
  * Index operations returning text (the ``->>`` operator)::
  
      data_table.c.data['some key'].astext == 'some value'
  
    Note that equivalent functionality is available via the
    :attr:`.JSON.Comparator.as_string` accessor.
  
  * Index operations with CAST
    (equivalent to ``CAST(col ->> ['some key'] AS <type>)``)::
  
      data_table.c.data['some key'].astext.cast(Integer) == 5
  
    Note that equivalent functionality is available via the
    :attr:`.JSON.Comparator.as_integer` and similar accessors.
  
  * Path index operations (the ``#>`` operator)::
  
      data_table.c.data[('key_1', 'key_2', 5, ..., 'key_n')]
  
  * Path index operations returning text (the ``#>>`` operator)::
  
      data_table.c.data[('key_1', 'key_2', 5, ..., 'key_n')].astext == 'some value'
  
  Index operations return an expression object whose type defaults to
  :class:`_types.JSON` by default,
  so that further JSON-oriented instructions
  may be called upon the result type.
  
  Custom serializers and deserializers are specified at the dialect level,
  that is using :func:`_sa.create_engine`.  The reason for this is that when
  using psycopg2, the DBAPI only allows serializers at the per-cursor
  or per-connection level.   E.g.::
  
      engine = create_engine("postgresql+psycopg2://scott:tiger@localhost/test",
                              json_serializer=my_serialize_fn,
                              json_deserializer=my_deserialize_fn
                      )
  
  When using the psycopg2 dialect, the json_deserializer is registered
  against the database using ``psycopg2.extras.register_default_json``.
  
  .. seealso::
  
      :class:`_types.JSON` - Core level JSON type
  
      :class:`_postgresql.JSONB`
class_docstr_tok: ["Represent","the","PostgreSQL","JSON","type",".",":","class",":","`","_postgresql.JSON","`","is","used","automatically","whenever","the","base",":","class",":","`","_types.JSON","`","datatype","is","used","against","a","PostgreSQL","backend",",","however","base",":","class",":","`","_types.JSON","`","datatype","does","not","provide","Python","accessors","for","PostgreSQL-specific","comparison","methods","such","as",":","meth",":","`","_postgresql.JSON.Comparator.astext","`",";","additionally",",","to","use","PostgreSQL","``","JSONB","``",",","the",":","class",":","`","_postgresql.JSONB","`","datatype","should","be","used","explicitly",".","..","seealso",":",":",":","class",":","`","_types.JSON","`","-","main","documentation","for","the","generic","cross-platform","JSON","datatype",".","The","operators","provided","by","the","PostgreSQL","version","of",":","class",":","`","_types.JSON","`","include",":","*","Index","operations","(","the","``","-",">","``","operator",")",":",":","data_table.c.data","[","'some","key","'","]","data_table.c.data","[","5","]","*","Index","operations","returning","text","(","the","``","-",">",">","``","operator",")",":",":","data_table.c.data","[","'some","key","'","]",".astext","==","'some","value'","Note","that","equivalent","functionality","is","available","via","the",":","attr",":","`",".JSON.Comparator.as_string","`","accessor",".","*","Index","operations","with","CAST","(","equivalent","to","``","CAST","(","col","-",">",">","[","'some","key","'","]","AS","<","type",">",")","``",")",":",":","data_table.c.data","[","'some","key","'","]",".astext.cast","(","Integer",")","==","5","Note","that","equivalent","functionality","is","available","via","the",":","attr",":","`",".JSON.Comparator.as_integer","`","and","similar","accessors",".","*","Path","index","operations","(","the","``","#",">","``","operator",")",":",":","data_table.c.data","[","(","'key_1","'",",","'key_2","'",",","5",",","...",",","'key_n","'",")","]","*","Path","index","operations","returning","text","(","the","``","#",">",">","``","operator",")",":",":","data_table.c.data","[","(","'key_1","'",",","'key_2","'",",","5",",","...",",","'key_n","'",")","]",".astext","==","'some","value'","Index","operations","return","an","expression","object","whose","type","defaults","to",":","class",":","`","_types.JSON","`","by","default",",","so","that","further","JSON-oriented","instructions","may","be","called","upon","the","result","type",".","Custom","serializers","and","deserializers","are","specified","at","the","dialect","level",",","that","is","using",":","func",":","`","_sa.create_engine","`",".","The","reason","for","this","is","that","when","using","psycopg2",",","the","DBAPI","only","allows","serializers","at","the","per-cursor","or","per-connection","level",".","E.g",".",":",":","engine","=","create_engine","(","``","postgresql+psycopg2",":","\/\/scott",":","tiger","@","localhost\/test","''",",","json_serializer=my_serialize_fn",",","json_deserializer=my_deserialize_fn",")","When","using","the","psycopg2","dialect",",","the","json_deserializer","is","registered","against","the","database","using","``","psycopg2.extras.register_default_json","``",".","..","seealso",":",":",":","class",":","`","_types.JSON","`","-","Core","level","JSON","type",":","class",":","`","_postgresql.JSONB","`"]
docstr: Construct a :class:`_types.JSON` type.
  
  :param none_as_null: if True, persist the value ``None`` as a
   SQL NULL value, not the JSON encoding of ``null``.   Note that
   when this flag is False, the :func:`.null` construct can still
   be used to persist a NULL value::
  
       from sqlalchemy import null
       conn.execute(table.insert(), data=null())
  
   .. seealso::
  
        :attr:`_types.JSON.NULL`
  
  :param astext_type: the type to use for the
   :attr:`.JSON.Comparator.astext`
   accessor on indexed attributes.  Defaults to :class:`_types.Text`.
docstr_tok: ["Construct","a",":","class",":","`","_types.JSON","`","type",".",":","param","none_as_null",":","if","True",",","persist","the","value","``","None","``","as","a","SQL","NULL","value",",","not","the","JSON","encoding","of","``","null","``",".","Note","that","when","this","flag","is","False",",","the",":","func",":","`",".null","`","construct","can","still","be","used","to","persist","a","NULL","value",":",":","from","sqlalchemy","import","null","conn.execute","(","table.insert","(",")",",","data=null","(",")",")","..","seealso",":",":",":","attr",":","`","_types.JSON.NULL","`",":","param","astext_type",":","the","type","to","use","for","the",":","attr",":","`",".JSON.Comparator.astext","`","accessor","on","indexed","attributes",".","Defaults","to",":","class",":","`","_types.Text","`","."]
code: def __init__(self, none_as_null=False, astext_type=None):
      """Construct a :class:`_types.JSON` type.
  
      :param none_as_null: if True, persist the value ``None`` as a
       SQL NULL value, not the JSON encoding of ``null``.   Note that
       when this flag is False, the :func:`.null` construct can still
       be used to persist a NULL value::
  
           from sqlalchemy import null
           conn.execute(table.insert(), data=null())
  
       .. seealso::
  
            :attr:`_types.JSON.NULL`
  
      :param astext_type: the type to use for the
       :attr:`.JSON.Comparator.astext`
       accessor on indexed attributes.  Defaults to :class:`_types.Text`.
  
      """
      super().__init__(none_as_null=none_as_null)
      if astext_type is not None:
          self.astext_type = astext_type
  
imports: from .array import ARRAY
  from .array import array
  from .operators import ASTEXT
  from .operators import CONTAINED_BY
  from .operators import CONTAINS
  from .operators import DELETE_PATH
  from .operators import HAS_ALL
  from .operators import HAS_ANY
  from .operators import HAS_KEY
  from .operators import JSONPATH_ASTEXT
  from .operators import PATH_EXISTS
  from .operators import PATH_MATCH
  from ...None import types
  from ...sql import cast
label_desc: Use image node_id 1 to create a new JSON object from inherited base classes: sqltypes with example: obj = JSON(none_as_null, astext_type)