Ñò
§ÚêLc @ sL d Z d d k Z d d k Z y d d k l Z Wn e j
o
d Z n Xd g Z e i d ƒ Z
e i d ƒ Z e i d ƒ Z h d d 6d
d 6d d
6d d 6d d 6d d 6d d 6Z
x3 e d ƒ D]% Z e
i e e ƒ d i e ƒ ƒ qÈ We Z e d „ Z d „ Z d „ Z e d j o
e Z n e Z d e f d „ ƒ YZ d S( s Implementation of JSONEncoder
iÿÿÿÿN( t encode_basestring_asciit JSONEncoders [\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}c C sŒ t i | ƒ o
d } nH t i | ƒ o- t i d | ƒ d j o
d } qa d } n t | ƒ S| p d t | ƒ } t | ƒ ‚ n | S( Nt NaNg ð?t Infinitys -Infinitys2 Out of range float values are not JSON compliant: ( t matht isnant isinft copysignt
FLOAT_REPRt reprt
ValueError( t ot allow_nant textt msg( ( s$ /usr/lib64/python2.6/json/encoder.pyt floatstr s
c C s! d „ } d t i | | ƒ d S( s5 Return a JSON representation of a Python string
c S s t | i d ƒ S( Ni ( t
ESCAPE_DCTt group( t match( ( s$ /usr/lib64/python2.6/json/encoder.pyt replace8 s R ( t ESCAPEt sub( t sR ( ( s$ /usr/lib64/python2.6/json/encoder.pyt encode_basestring4 s c C s` t | t ƒ o) t i | ƒ d j o | i d ƒ } n d „ } d t t i | | ƒ ƒ d S( Ns utf-8c S s– | i d ƒ } y t | SWnt t j
oh t | ƒ } | d j o d i | ƒ S| d 8} d | d ?d @B} d | d @B} d i | | ƒ 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/lib64/python2.6/json/encoder.pyR @ s
R ( t
isinstancet strt HAS_UTF8t searcht Nonet decodet ESCAPE_ASCIIR ( R R ( ( s$ /usr/lib64/python2.6/json/encoder.pyt py_encode_basestring_ascii= s & c
B s¤ e Z d Z d d d d g Z d Z d Z e e e e e d d d d d „ Z d „ Z
d d
„ Z d d „ Z d d „ Z
d d
„ Z d „ Z d „ Z 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``).
t __init__t defaultt encodet
iterencodes , s : s utf-8c
C s‰ | | _ | | _ | | _ | | _ | | _ | | _ d | _ | d j o | \ | _ | _ n | d j o
| | _
n | | _ d S( s0 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 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.
i N( t skipkeyst ensure_asciit check_circularR
t sort_keyst indentt current_indent_levelR# t item_separatort
key_separatorR( t encoding(
t selfR+ R, R- R
R. R/ t
separatorsR3 R( ( ( s$ /usr/lib64/python2.6/json/encoder.pyR' w s -
c C s d d | i | i S( Ns
t ( R/ R0 ( R4 ( ( s$ /usr/lib64/python2.6/json/encoder.pyt _newline_indent± s c c sE | p
d Vd S| d j o7 t | ƒ } | | j o t d ƒ ‚ n | | |