Ñò §ÚêLc @sLdZddkZddkZyddklZWnej o dZnXdgZei dƒZ ei dƒZ ei dƒZ hdd 6d d 6d d 6dd6dd6dd6dd6Z x3edƒD]%Ze ieeƒdieƒƒqÈWeZed„Zd„Zd„Zedj o eZneZdefd„ƒYZdS(sImplementation of JSONEncoder iÿÿÿÿN(tencode_basestring_asciit JSONEncoders[\x00-\x1f\\"\b\f\n\r\t]s([\\"]|[^\ -~])s [\x80-\xff]s\\s\s\"t"s\bss\fs s\ns s\rs s\ts i s \u{0:04x}cCsŒti|ƒo d}nHti|ƒo-tid|ƒdjo d}qad}n t|ƒS|p dt|ƒ}t|ƒ‚n|S(NtNaNgð?tInfinitys -Infinitys2Out of range float values are not JSON compliant: (tmathtisnantisinftcopysignt FLOAT_REPRtreprt ValueError(tot allow_nanttexttmsg((s$/usr/lib64/python2.6/json/encoder.pytfloatstrs    cCs!d„}dti||ƒdS(s5Return a JSON representation of a Python string cSst|idƒS(Ni(t ESCAPE_DCTtgroup(tmatch((s$/usr/lib64/python2.6/json/encoder.pytreplace8sR(tESCAPEtsub(tsR((s$/usr/lib64/python2.6/json/encoder.pytencode_basestring4s cCs`t|tƒo)ti|ƒdj o|idƒ}nd„}dtti||ƒƒdS(Nsutf-8cSs–|idƒ}y t|SWnttj oht|ƒ}|djodi|ƒS|d8}d|d?d@B}d|d@B}di||ƒSnXdS( Niis \u{0:04x}iØi iÿiÜs\u{0:04x}\u{1:04x}(RRtKeyErrortordtformat(RRtnts1ts2((s$/usr/lib64/python2.6/json/encoder.pyR@s    R(t isinstancetstrtHAS_UTF8tsearchtNonetdecodet ESCAPE_ASCIIR(RR((s$/usr/lib64/python2.6/json/encoder.pytpy_encode_basestring_ascii=s& c Bs¤eZdZddddgZdZdZeeeeeddddd„ Z d „Z dd „Z dd „Z dd „Z dd „Zd„Zd„Zd„ZRS(sZExtensible 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``). t__init__tdefaulttencodet iterencodes, s: sutf-8c Cs‰||_||_||_||_||_||_d|_|dj o|\|_|_ n| dj o | |_ n||_ dS(s0Constructor 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 output is guaranteed to be str objects with all incoming unicode characters escaped. If ensure_ascii is false, the output will be unicode object. 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. 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. iN( tskipkeyst ensure_asciitcheck_circularR t sort_keystindenttcurrent_indent_levelR#titem_separatort key_separatorR(tencoding( tselfR+R,R-R R.R/t separatorsR3R(((s$/usr/lib64/python2.6/json/encoder.pyR'ws-          cCsdd|i|iS(Ns t (R/R0(R4((s$/usr/lib64/python2.6/json/encoder.pyt_newline_indent±sc csE|p dVdS|dj o7t|ƒ}||jotdƒ‚n|||}|o t}n|Vx|i ||ƒD] }|VqæWq·W|dj o|id8_|iƒVndV|dj o ||=ndS(Ns[]sCircular reference detectedt[it]( R#tidR R/R0R7R1tTruetFalset _iterencode( R4tlsttmarkerstmarkeridtnewline_indentt separatortfirsttvaluetchunk((s$/usr/lib64/python2.6/json/encoder.pyt_iterencode_list´s>           ccsû|p dVdS|dj o7t|ƒ}||jotdƒ‚n||||djo d}n'|ioqantd i|ƒƒ‚|o t}n|V||ƒV|Vx|i||ƒD] }|VqœWqaW|dj o|id8_|iƒVnd V|dj o ||=ndS( Ns{}sCircular reference detectedt{isutf-8ttruetfalsetnullskey {0!r} is not a stringt}(R#R:R R2R/R0R7R1R;R,RRR R.tkeystsortt iteritemsR3RR R$t basestringtfloatRtinttlongR<R+t TypeErrorRR=(R4tdctR?R@R2RAR1RCtencoderR RLt_[1]tktitemst _encodingt _do_decodetkeyRDRE((s$/usr/lib64/python2.6/json/encoder.pyt_iterencode_dictÕs€              /                 ccst|tƒop|io t}nt}|i}|dj o1t|tƒo!|dj o|i|ƒ}n||ƒVn}|djo dVng|t jo dVnQ|t jo dVn;t|t t fƒot|ƒVnt|t ƒot||iƒVnñt|ttfƒo&x×|i||ƒD] }|Vq5Wnµt|tƒo&x¡|i||ƒD] }|VqkWn|dj o7t|ƒ}||jotdƒ‚n|||>> JSONEncoder().encode({"foo": ["bar", "baz"]}) '{"foo": ["bar", "baz"]}' sutf-8tN( RROR R3R#R$R,RRR]R*tjoin(R4R RYtchunks((s$/usr/lib64/python2.6/json/encoder.pyR)Zs    cCs*|io h}nd}|i||ƒS(sØEncode the given object and yield each string representation as available. For example:: for chunk in JSONEncoder().iterencode(bigobject): mysocket.write(chunk) N(R-R#R=(R4R R?((s$/usr/lib64/python2.6/json/encoder.pyR*rs  N(t__name__t __module__t__doc__t__all__R1R2R<R;R#R'R7RFR\R=R`R(R)R*(((s$/usr/lib64/python2.6/json/encoder.pyRWs 8  ! G &   (RgtreRt_jsonRtc_encode_basestring_asciit ImportErrorR#RhtcompileRR%R!Rtrangetit setdefaulttchrRR R R;RRR&tobjectR(((s$/usr/lib64/python2.6/json/encoder.pyts:      #