Server: appserver-7f0f8755-nginx-15961cad18524ec5a9db05f2a6a7e440
Current directory: /usr/lib/python2.7/json
Software: nginx/1.27.5
Shell Command
Create a new file
Upload file
File: encoder.pyc
� ӫ[c @ s d Z d d l Z y d d l m Z Wn e k r? d Z n Xy d d l m Z Wn e k rm d Z n Xe j d � Z e j d � Z e j d � Z i d d 6d d 6d d 6d d 6d d 6d d 6d d 6Z x3 e d � D]% Z e j e e � d j e � � q� We d � Z e j Z d � Z d � Z e p8e Z d e f d � � YZ e e e e e e e e! e" e# e$ d � Z% d S( s Implementation of JSONEncoder i����N( t encode_basestring_ascii( t make_encoders [\x00-\x1f\\"\b\f\n\r\t]s ([\\"]|[^\ -~])s [\x80-\xff]s \\s \s \"t "s \bs s \fs s \ns s \rs s \ts i s \u{0:04x}t infc C s! d � } d t j | | � d S( s5 Return a JSON representation of a Python string c S s t | j d � S( Ni ( t ESCAPE_DCTt group( t match( ( s" /usr/lib/python2.7/json/encoder.pyt replace% s R ( t ESCAPEt sub( t sR ( ( s" /usr/lib/python2.7/json/encoder.pyt encode_basestring! s c C s] t | t � r6 t j | � d k r6 | j d � } n d � } d t t j | | � � d S( sA Return an ASCII-only JSON representation of a Python string s utf-8c S s� | j d � } y t | SWnp t k r� t | � } | d k rP d j | � S| d 8} d | d ?d @B} d | d @B} d j | | � Sn Xd S( Ni i s \u{0:04x}i � i i� i � s \u{0:04x}\u{1:04x}( R R t KeyErrort ordt format( R R t nt s1t s2( ( s" /usr/lib/python2.7/json/encoder.pyR 0 s R N( t isinstancet strt HAS_UTF8t searcht Nonet decodet ESCAPE_ASCIIR ( R R ( ( s" /usr/lib/python2.7/json/encoder.pyt py_encode_basestring_ascii* s $ t JSONEncoderc B s\ e Z d Z d Z d Z e e e e e d d d d d � Z d � Z d � Z e d � Z RS( sZ Extensible JSON
encoder for Python data structures. Supports the following objects and types by default: +-------------------+---------------+ | Python | JSON | +===================+===============+ | dict | object | +-------------------+---------------+ | list, tuple | array | +-------------------+---------------+ | str, unicode | string | +-------------------+---------------+ | int, long, float | number | +-------------------+---------------+ | True | true | +-------------------+---------------+ | False | false | +-------------------+---------------+ | None | null | +-------------------+---------------+ To extend this to recognize other objects, subclass and implement a ``.default()`` method with another method that returns a serializable object for ``o`` if possible, otherwise it should call the superclass implementation (to raise ``TypeError``). s , s : s utf-8c C s| | | _ | | _ | | _ | | _ | | _ | | _ | d k rW | \ | _ | _ n | d k ro | | _ n | | _ d S( s� Constructor for JSONEncoder, with sensible defaults. If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, long, float or None. If skipkeys is True, such items are simply skipped. If *ensure_ascii* is true (the default), all non-ASCII characters in the output are escaped with \uXXXX sequences, and the results are str instances consisting of ASCII characters only. If ensure_ascii is False, a result may be a unicode instance. This usually happens if the input contains unicode strings or the *encoding* parameter is used. If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an OverflowError). Otherwise, no such check takes place. If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats. If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis. If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation. Since the default item separator is ', ', the output might include trailing whitespace when indent is specified. You can use separators=(',', ': ') to avoid this. If specified, separators should be a (item_separator, key_separator) tuple. The default is (', ', ': '). To get the most compact JSON representation you should specify (',', ':') to eliminate whitespace. If specified, default is a function that gets called for objects that can't otherwise be serialized. It should return a JSON encodable version of the object or raise a ``TypeError``. If encoding is not None, then all input strings will be transformed into unicode using that encoding prior to JSON-encoding. The default is UTF-8. N( t skipkeyst ensure_asciit check_circulart allow_nant sort_keyst indentR t item_separatort key_separatort defaultt encoding( t selfR R R R R R t separatorsR$ R# ( ( s" /usr/lib/python2.7/json/encoder.pyt __init__e s 4 c C s t t | � d � � d S( sl Implement this method in a subclass such that it returns a serializable object for ``o``, or calls the base implementation (to raise a ``TypeError``). For example, to support arbitrary iterators, you could implement default like this:: def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o) s is not JSON serializableN( t TypeErrort repr( R% t o( ( s" /usr/lib/python2.7/json/encoder.pyR# � s c C s� t | t � ru t | t � rU | j } | d k rU | d k rU | j | � } qU n | j rh t | � St | � Sn | j | d t �} t | t t f � s� t | � } n d j | � S( s� Return a JSON string representation of a Python data structure. >>> JSONEncoder().encode({"foo": ["bar", "baz"]}) '{"foo": ["bar", "baz"]}' s utf-8t _one_shott N( R t basestringR R$ R R R R R t iterencodet Truet listt tuplet join( R% R* t _encodingt chunks( ( s" /usr/lib/python2.7/json/encoder.pyt encode� s c C s | j r i } n d } | j r* t } n t } | j d k rT | | j d � } n | j t t t d � } | r� t d k r� | j d k r� | j r� t | | j | | j | j | j | j | j | j � } n9 t | | j | | j | | j | j | j | j | � } | | d � S( s� Encode the given object and yield each string representation as available. For example:: for chunk in JSONEncoder().iterencode(bigobject): mysocket.write(chunk) s utf-8c S s+ t | t � r! | j | � } n | | � S( N( R R R ( R* t _orig_encoderR3 ( ( s" /usr/lib/python2.7/json/encoder.pyt _encoder� s c S sl | | k r d } n4 | | k r* d } n | | k r? d } n | | � S| sh t d t | � � � n | S( Nt NaNt Infinitys -Infinitys2 Out of range float values are not JSON compliant: ( t ValueErrorR) ( R* R t _reprt _inft _neginft text( ( s" /usr/lib/python2.7/json/encoder.pyt floatstr� s i N( R R R R R R$ R t FLOAT_REPRt INFINITYt c_make_encoderR R R# R" R! R t _make_iterencode( R% R* R+ t markersR7 R? t _iterencode( ( s" /usr/lib/python2.7/json/encoder.pyR. � s* N( t __name__t __module__t __doc__R! R" t FalseR/ R R' R# R5 R. ( ( ( s" /usr/lib/python2.7/json/encoder.pyR F s > c s� � � � � � � � � � � � � � � � � � � � f d � � � � � � � � � � � � � � � � � � � � � � � � f d � � � � � � � � � � � � � � � � � � � � f d � � � S( Nc 3 s8 | s d Vd S� d k rO � | � } | � k rB � d � � n | � |