//usr/lib64/lib64//lib64/lib64//ó
ÚœSec
@ 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 Z d „ Z d „ Z e p5e 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/lib64/python2.7/json/encoder.pyt replace% s R ( t ESCAPEt sub( t sR ( ( s$ /usr/lib64/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/lib64/python2.7/json/encoder.pyR 0 s
R N( t
isinstancet strt HAS_UTF8t searcht Nonet decodet ESCAPE_ASCIIR ( R
R ( ( s$ /usr/lib64/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/lib64/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/lib64/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/lib64/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/lib64/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/lib64/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/lib64/python2.7/json/encoder.pyR. Ô s*
N( t __name__t
__module__t __doc__R! R" t FalseR/ R R' R# R5 R. ( ( ( s$ /usr/lib64/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 | ˆ |