]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
import simplejson-1.7.1 into src/simplejson
authorBrian Warner <warner@lothar.com>
Tue, 10 Jul 2007 22:22:53 +0000 (15:22 -0700)
committerBrian Warner <warner@lothar.com>
Tue, 10 Jul 2007 22:22:53 +0000 (15:22 -0700)
47 files changed:
src/simplejson/LICENSE.txt [new file with mode: 0644]
src/simplejson/PKG-INFO [new file with mode: 0644]
src/simplejson/docs/class-simplejson.JSONDecoder.html [new file with mode: 0644]
src/simplejson/docs/class-simplejson.JSONEncoder.html [new file with mode: 0644]
src/simplejson/docs/class_to_source.js [new file with mode: 0644]
src/simplejson/docs/index.html [new file with mode: 0644]
src/simplejson/docs/layout.css [new file with mode: 0644]
src/simplejson/docs/module-index.html [new file with mode: 0644]
src/simplejson/docs/module-simplejson-index.html [new file with mode: 0644]
src/simplejson/docs/module-simplejson.html [new file with mode: 0644]
src/simplejson/docs/pudge.css [new file with mode: 0644]
src/simplejson/docs/rst.css [new file with mode: 0644]
src/simplejson/docs/simplejson/__init__.py.html [new file with mode: 0644]
src/simplejson/docs/simplejson/decoder.py.html [new file with mode: 0644]
src/simplejson/docs/simplejson/encoder.py.html [new file with mode: 0644]
src/simplejson/docs/simplejson/jsonfilter.py.html [new file with mode: 0644]
src/simplejson/docs/simplejson/scanner.py.html [new file with mode: 0644]
src/simplejson/ez_setup/README.txt [new file with mode: 0644]
src/simplejson/ez_setup/__init__.py [new file with mode: 0644]
src/simplejson/scripts/bench.sh [new file with mode: 0644]
src/simplejson/scripts/make_docs.py [new file with mode: 0644]
src/simplejson/scripts/prof.py [new file with mode: 0644]
src/simplejson/setup.cfg [new file with mode: 0644]
src/simplejson/setup.py [new file with mode: 0644]
src/simplejson/simplejson.egg-info/PKG-INFO [new file with mode: 0644]
src/simplejson/simplejson.egg-info/SOURCES.txt [new file with mode: 0644]
src/simplejson/simplejson.egg-info/dependency_links.txt [new file with mode: 0644]
src/simplejson/simplejson.egg-info/entry_points.txt [new file with mode: 0644]
src/simplejson/simplejson.egg-info/top_level.txt [new file with mode: 0644]
src/simplejson/simplejson.egg-info/zip-safe [new file with mode: 0644]
src/simplejson/simplejson/__init__.py [new file with mode: 0644]
src/simplejson/simplejson/_speedups.c [new file with mode: 0644]
src/simplejson/simplejson/decoder.py [new file with mode: 0644]
src/simplejson/simplejson/encoder.py [new file with mode: 0644]
src/simplejson/simplejson/jsonfilter.py [new file with mode: 0644]
src/simplejson/simplejson/scanner.py [new file with mode: 0644]
src/simplejson/simplejson/tests/__init__.py [new file with mode: 0644]
src/simplejson/simplejson/tests/test_attacks.py [new file with mode: 0644]
src/simplejson/simplejson/tests/test_dump.py [new file with mode: 0644]
src/simplejson/simplejson/tests/test_fail.py [new file with mode: 0644]
src/simplejson/simplejson/tests/test_indent.py [new file with mode: 0644]
src/simplejson/simplejson/tests/test_pass1.py [new file with mode: 0644]
src/simplejson/simplejson/tests/test_pass2.py [new file with mode: 0644]
src/simplejson/simplejson/tests/test_pass3.py [new file with mode: 0644]
src/simplejson/simplejson/tests/test_recursion.py [new file with mode: 0644]
src/simplejson/simplejson/tests/test_separators.py [new file with mode: 0644]
src/simplejson/simplejson/tests/test_unicode.py [new file with mode: 0644]

diff --git a/src/simplejson/LICENSE.txt b/src/simplejson/LICENSE.txt
new file mode 100644 (file)
index 0000000..ad95f29
--- /dev/null
@@ -0,0 +1,19 @@
+Copyright (c) 2006 Bob Ippolito
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/src/simplejson/PKG-INFO b/src/simplejson/PKG-INFO
new file mode 100644 (file)
index 0000000..c202c5f
--- /dev/null
@@ -0,0 +1,29 @@
+Metadata-Version: 1.0
+Name: simplejson
+Version: 1.7.1
+Summary: Simple, fast, extensible JSON encoder/decoder for Python
+Home-page: http://undefined.org/python/#simplejson
+Author: Bob Ippolito
+Author-email: bob@redivi.com
+License: MIT License
+Description: 
+        simplejson is a simple, fast, complete, correct and extensible
+        JSON <http://json.org> encoder and decoder for Python 2.3+.  It is
+        pure Python code with no dependencies, but includes an optional C
+        extension for a serious speed boost.
+        
+        simplejson was formerly known as simple_json, but changed its name to
+        comply with PEP 8 module naming guidelines.
+        
+        The encoder may be subclassed to provide serialization in any kind of
+        situation, without any special support by the objects to be serialized
+        (somewhat like pickle).
+        
+        The decoder can handle incoming JSON strings of any specified encoding
+        (UTF-8 by default).
+        
+Platform: any
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Programming Language :: Python
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/src/simplejson/docs/class-simplejson.JSONDecoder.html b/src/simplejson/docs/class-simplejson.JSONDecoder.html
new file mode 100644 (file)
index 0000000..c5f31ff
--- /dev/null
@@ -0,0 +1,210 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<HTML>
+  
+  <HEAD><META CONTENT="text/html; charset=utf-8" HTTP-EQUIV="Content-Type">
+    <TITLE>simplejson.JSONDecoder -- Simple JSON &amp;lt;&lt;a class="reference" href="http://json.org">http://json.org&lt;/a>&amp;gt; decoder</TITLE>
+    <LINK HREF="layout.css" TYPE="text/css" REL="stylesheet">
+  </HEAD>
+  <BODY>
+    <DIV ID="page">
+      
+    <DIV ID="top-nav">
+        <H1 ID="doc-title"><A HREF="index.html" REL="index">simplejson 1.7.1</A></H1>
+        <DIV CLASS="online-navigation">
+          <A HREF="index.html" REL="index">index</A>
+          <SPAN ID="nav-docs">
+            
+          </SPAN>
+          
+          
+
+          <BR>
+
+          <A HREF="module-simplejson.html" TITLE="simplejson reference">
+            simplejson
+          </A>
+
+          
+            
+            <A HREF="class-simplejson.JSONDecoder.html">details</A>
+            
+            <A HREF="class-simplejson.JSONDecoder-index.html">
+              tree
+            </A>
+            
+          
+        </DIV>
+    </DIV>
+    
+    <DIV ID="main-content">
+  
+  <H1 CLASS="pudge-member-page-heading">
+    <TT>JSONDecoder</TT>
+  </H1>
+  <H4 CLASS="pudge-member-page-subheading">
+    Simple JSON &lt;<A HREF="http://json.org" CLASS="reference">http://json.org</A>> decoder
+  </H4>
+  <P CLASS="pudge-member-parent-link">
+    <SMALL>
+    The JSONDecoder class is accessible via the
+    <A HREF="module-simplejson.html">
+      <TT>simplejson</TT>
+    </A> module.
+    </SMALL>
+  </P>
+  <DIV ID="pudge-section-nav">
+  <UL>
+    <LI>
+      
+      <SPAN CLASS="pudge-missing-section-link">
+        Attributes
+      </SPAN>
+    </LI><LI>
+      <A HREF="#methods" CLASS="pudge-section-link">
+        Methods (3)
+      </A>
+      
+    </LI>
+    
+    <LI>
+      <A HREF="simplejson/decoder.py.html?f=196&amp;l=272#196" CLASS="pudge-section-link">
+        Source
+      </A>
+    </LI>
+  </UL>
+  </DIV>
+  <DIV STYLE="clear: left"></DIV>
+  <DIV CLASS="rst pudge-module-doc">
+    <P>Performs the following translations in decoding:</P>
+<TABLE BORDER="1" CLASS="docutils">
+<COLGROUP>
+<COL WIDTH="44%">
+<COL WIDTH="56%">
+</COLGROUP>
+<THEAD VALIGN="bottom">
+<TR><TH CLASS="head">JSON</TH>
+<TH CLASS="head">Python</TH>
+</TR>
+</THEAD>
+<TBODY VALIGN="top">
+<TR><TD>object</TD>
+<TD>dict</TD>
+</TR>
+<TR><TD>array</TD>
+<TD>list</TD>
+</TR>
+<TR><TD>string</TD>
+<TD>unicode</TD>
+</TR>
+<TR><TD>number (int)</TD>
+<TD>int, long</TD>
+</TR>
+<TR><TD>number (real)</TD>
+<TD>float</TD>
+</TR>
+<TR><TD>true</TD>
+<TD>True</TD>
+</TR>
+<TR><TD>false</TD>
+<TD>False</TD>
+</TR>
+<TR><TD>null</TD>
+<TD>None</TD>
+</TR>
+</TBODY>
+</TABLE>
+<P>It also understands <TT CLASS="docutils literal"><SPAN CLASS="pre">NaN</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">Infinity</SPAN></TT>, and <TT CLASS="docutils literal"><SPAN CLASS="pre">-Infinity</SPAN></TT> as
+their corresponding <TT CLASS="docutils literal"><SPAN CLASS="pre">float</SPAN></TT> values, which is outside the JSON spec.</P>
+
+  </DIV>
+  
+  <HR>
+  
+  
+    <A NAME="methods"></A>
+    <H2>Methods</H2>
+    <DIV CLASS="pudge-member routine alias">
+    <A NAME="__init__"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="class-simplejson.JSONDecoder.html#__init__" CLASS="pudge-obj-link">__init__</A>(self, encoding=None, object_hook=None)</TT>
+      <A HREF="simplejson/decoder.py.html?f=229&amp;l=245#229" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      <TT CLASS="docutils literal"><SPAN CLASS="pre">encoding</SPAN></TT> determines the encoding used to interpret any <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT>
+objects decoded by this instance (utf-8 by default).  It has no
+effect when decoding <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> objects.
+    </P>
+    <P>Note that currently only encodings that are a superset of ASCII work,
+strings of other encodings should be passed in as <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT>.</P>
+<P><TT CLASS="docutils literal"><SPAN CLASS="pre">object_hook</SPAN></TT>, if specified, will be called with the result
+of every JSON object decoded and its return value will be used in
+place of the given <TT CLASS="docutils literal"><SPAN CLASS="pre">dict</SPAN></TT>.  This can be used to provide custom
+deserializations (e.g. to support JSON-RPC class hinting).</P>
+
+  
+    </DIV>
+  </DIV><DIV CLASS="pudge-member routine alias">
+    <A NAME="decode"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="class-simplejson.JSONDecoder.html#decode" CLASS="pudge-obj-link">decode</A>(self, s, _w=&lt;built-in method match of _sre.SRE_Pattern object at 0x13244a0>)</TT>
+      <A HREF="simplejson/decoder.py.html?f=246&amp;l=256#246" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Return the Python representation of <TT CLASS="docutils literal"><SPAN CLASS="pre">s</SPAN></TT> (a <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT> or <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT>
+instance containing a JSON document)
+    </P>
+    
+  
+    </DIV>
+  </DIV><DIV CLASS="pudge-member routine alias">
+    <A NAME="raw_decode"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="class-simplejson.JSONDecoder.html#raw_decode" CLASS="pudge-obj-link">raw_decode</A>(self, s, **kw)</TT>
+      <A HREF="simplejson/decoder.py.html?f=257&amp;l=272#257" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Decode a JSON document from <TT CLASS="docutils literal"><SPAN CLASS="pre">s</SPAN></TT> (a <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT> or <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> beginning
+with a JSON document) and return a 2-tuple of the Python
+representation and the index in <TT CLASS="docutils literal"><SPAN CLASS="pre">s</SPAN></TT> where the document ended.
+    </P>
+    <P>This can be used to decode a JSON document from a string that may
+have extraneous data at the end.</P>
+
+  
+    </DIV>
+  </DIV>
+    
+  
+  
+  <P>
+    <SMALL>
+    
+    
+    See 
+    <A HREF="simplejson/decoder.py.html?f=196&amp;l=272#196" TITLE="simplejson/decoder.py:196">the source</A>
+    for more information.
+    </SMALL>
+  </P>
+
+</DIV>
+    
+    <DIV ID="footer">
+      
+      <P ID="pudge">
+        Built with
+        <A HREF="http://lesscode.org/projects/pudge/">
+          Pudge/0.1.3</A>
+      </P>
+
+      
+    </DIV>
+    </DIV>
+  </BODY>
+
+</HTML>
\ No newline at end of file
diff --git a/src/simplejson/docs/class-simplejson.JSONEncoder.html b/src/simplejson/docs/class-simplejson.JSONEncoder.html
new file mode 100644 (file)
index 0000000..1e42961
--- /dev/null
@@ -0,0 +1,261 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<HTML>
+  
+  <HEAD><META CONTENT="text/html; charset=utf-8" HTTP-EQUIV="Content-Type">
+    <TITLE>simplejson.JSONEncoder -- Extensible JSON &amp;lt;&lt;a class="reference" href="http://json.org">http://json.org&lt;/a>&amp;gt; encoder for Python data structures.</TITLE>
+    <LINK HREF="layout.css" TYPE="text/css" REL="stylesheet">
+  </HEAD>
+  <BODY>
+    <DIV ID="page">
+      
+    <DIV ID="top-nav">
+        <H1 ID="doc-title"><A HREF="index.html" REL="index">simplejson 1.7.1</A></H1>
+        <DIV CLASS="online-navigation">
+          <A HREF="index.html" REL="index">index</A>
+          <SPAN ID="nav-docs">
+            
+          </SPAN>
+          
+          
+
+          <BR>
+
+          <A HREF="module-simplejson.html" TITLE="simplejson reference">
+            simplejson
+          </A>
+
+          
+            
+            <A HREF="class-simplejson.JSONEncoder.html">details</A>
+            
+            <A HREF="class-simplejson.JSONEncoder-index.html">
+              tree
+            </A>
+            
+          
+        </DIV>
+    </DIV>
+    
+    <DIV ID="main-content">
+  
+  <H1 CLASS="pudge-member-page-heading">
+    <TT>JSONEncoder</TT>
+  </H1>
+  <H4 CLASS="pudge-member-page-subheading">
+    Extensible JSON &lt;<A HREF="http://json.org" CLASS="reference">http://json.org</A>> encoder for Python data structures.
+  </H4>
+  <P CLASS="pudge-member-parent-link">
+    <SMALL>
+    The JSONEncoder class is accessible via the
+    <A HREF="module-simplejson.html">
+      <TT>simplejson</TT>
+    </A> module.
+    </SMALL>
+  </P>
+  <DIV ID="pudge-section-nav">
+  <UL>
+    <LI>
+      
+      <SPAN CLASS="pudge-missing-section-link">
+        Attributes
+      </SPAN>
+    </LI><LI>
+      <A HREF="#methods" CLASS="pudge-section-link">
+        Methods (4)
+      </A>
+      
+    </LI>
+    
+    <LI>
+      <A HREF="simplejson/encoder.py.html?f=80&amp;l=370#80" CLASS="pudge-section-link">
+        Source
+      </A>
+    </LI>
+  </UL>
+  </DIV>
+  <DIV STYLE="clear: left"></DIV>
+  <DIV CLASS="rst pudge-module-doc">
+    <P>Supports the following objects and types by default:</P>
+<TABLE BORDER="1" CLASS="docutils">
+<COLGROUP>
+<COL WIDTH="56%">
+<COL WIDTH="44%">
+</COLGROUP>
+<THEAD VALIGN="bottom">
+<TR><TH CLASS="head">Python</TH>
+<TH CLASS="head">JSON</TH>
+</TR>
+</THEAD>
+<TBODY VALIGN="top">
+<TR><TD>dict</TD>
+<TD>object</TD>
+</TR>
+<TR><TD>list, tuple</TD>
+<TD>array</TD>
+</TR>
+<TR><TD>str, unicode</TD>
+<TD>string</TD>
+</TR>
+<TR><TD>int, long, float</TD>
+<TD>number</TD>
+</TR>
+<TR><TD>True</TD>
+<TD>true</TD>
+</TR>
+<TR><TD>False</TD>
+<TD>false</TD>
+</TR>
+<TR><TD>None</TD>
+<TD>null</TD>
+</TR>
+</TBODY>
+</TABLE>
+<P>To extend this to recognize other objects, subclass and implement a
+<TT CLASS="docutils literal"><SPAN CLASS="pre">.default()</SPAN></TT> method with another method that returns a serializable
+object for <TT CLASS="docutils literal"><SPAN CLASS="pre">o</SPAN></TT> if possible, otherwise it should call the superclass
+implementation (to raise <TT CLASS="docutils literal"><SPAN CLASS="pre">TypeError</SPAN></TT>).</P>
+
+  </DIV>
+  
+  <HR>
+  
+  
+    <A NAME="methods"></A>
+    <H2>Methods</H2>
+    <DIV CLASS="pudge-member routine alias">
+    <A NAME="__init__"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="class-simplejson.JSONEncoder.html#__init__" CLASS="pudge-obj-link">__init__</A>(self, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, encoding='utf-8')</TT>
+      <A HREF="simplejson/encoder.py.html?f=112&amp;l=164#112" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Constructor for JSONEncoder, with sensible defaults.
+    </P>
+    <P>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.</P>
+<P>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.</P>
+<P>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.</P>
+<P>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.</P>
+<P>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.</P>
+<P>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.</P>
+<P>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.</P>
+<P>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.</P>
+
+  
+    </DIV>
+  </DIV><DIV CLASS="pudge-member routine alias">
+    <A NAME="default"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="class-simplejson.JSONEncoder.html#default" CLASS="pudge-obj-link">default</A>(self, o)</TT>
+      <A HREF="simplejson/encoder.py.html?f=314&amp;l=333#314" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Implement this method in a subclass such that it returns
+a serializable object for <TT CLASS="docutils literal"><SPAN CLASS="pre">o</SPAN></TT>, or calls the base implementation
+(to raise a <TT CLASS="docutils literal"><SPAN CLASS="pre">TypeError</SPAN></TT>).
+    </P>
+    <P>For example, to support arbitrary iterators, you could
+implement default like this:</P>
+<PRE CLASS="literal-block">
+def default(self, o):
+    try:
+        iterable = iter(o)
+    except TypeError:
+        pass
+    else:
+        return list(iterable)
+    return JSONEncoder.default(self, o)
+</PRE>
+
+  
+    </DIV>
+  </DIV><DIV CLASS="pudge-member routine alias">
+    <A NAME="encode"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="class-simplejson.JSONEncoder.html#encode" CLASS="pudge-obj-link">encode</A>(self, o)</TT>
+      <A HREF="simplejson/encoder.py.html?f=334&amp;l=354#334" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Return a JSON string representation of a Python data structure.
+    </P>
+    <PRE CLASS="doctest-block">
+>>> JSONEncoder().encode({"foo": ["bar", "baz"]})
+'{"foo":["bar", "baz"]}'
+</PRE>
+
+  
+    </DIV>
+  </DIV><DIV CLASS="pudge-member routine alias">
+    <A NAME="iterencode"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="class-simplejson.JSONEncoder.html#iterencode" CLASS="pudge-obj-link">iterencode</A>(self, o)</TT>
+      <A HREF="simplejson/encoder.py.html?f=355&amp;l=370#355" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Encode the given object and yield each string
+representation as available.
+    </P>
+    <P>For example:</P>
+<PRE CLASS="literal-block">
+for chunk in JSONEncoder().iterencode(bigobject):
+    mysocket.write(chunk)
+</PRE>
+
+  
+    </DIV>
+  </DIV>
+    
+  
+  
+  <P>
+    <SMALL>
+    
+    
+    See 
+    <A HREF="simplejson/encoder.py.html?f=80&amp;l=370#80" TITLE="simplejson/encoder.py:80">the source</A>
+    for more information.
+    </SMALL>
+  </P>
+
+</DIV>
+    
+    <DIV ID="footer">
+      
+      <P ID="pudge">
+        Built with
+        <A HREF="http://lesscode.org/projects/pudge/">
+          Pudge/0.1.3</A>
+      </P>
+
+      
+    </DIV>
+    </DIV>
+  </BODY>
+
+</HTML>
\ No newline at end of file
diff --git a/src/simplejson/docs/class_to_source.js b/src/simplejson/docs/class_to_source.js
new file mode 100644 (file)
index 0000000..b6dc765
--- /dev/null
@@ -0,0 +1,22 @@
+(function () {
+    var href = document.location.href;
+    if (href.indexOf("file:") == 0 || !document.getElementsByTagName) return;
+    var _old_onload = window.onload;
+    window.onload = function () {
+        if (_old_onload) _old_onload.call(this);
+        _old_onload = null;
+        var anchors = document.getElementsByTagName('A');
+        var class_re = /\blines-(\d+)-(\d+)\b/;
+        var hash_re = /#.*$/;
+        for (var i = 0; i < anchors.length; i++) {
+            var anchor = anchors[i];
+            var found = anchor.className.match(class_re);
+            if (!found) continue;
+            href = anchor.href;
+            var hashidx = href.indexOf("#");
+            if (hashidx == -1) hashidx = href.length;
+            anchor.href = (href.substring(0, hashidx) + "?f=" + found[1] +
+                "&l=" + found[2] + href.substring(hashidx, href.length));
+        }
+    }
+})();
diff --git a/src/simplejson/docs/index.html b/src/simplejson/docs/index.html
new file mode 100644 (file)
index 0000000..c142f3f
--- /dev/null
@@ -0,0 +1,455 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<HTML>
+  
+  <HEAD><META CONTENT="text/html; charset=utf-8" HTTP-EQUIV="Content-Type">
+    <TITLE>simplejson -- A simple, fast, extensible JSON encoder and decoder</TITLE>
+    <LINK HREF="layout.css" TYPE="text/css" REL="stylesheet">
+  </HEAD>
+  <BODY>
+    <DIV ID="page">
+      
+    <DIV ID="top-nav">
+        <H1 ID="doc-title"><A HREF="index.html" REL="index">simplejson 1.7.1</A></H1>
+        <DIV CLASS="online-navigation">
+          <A HREF="index.html" REL="index">index</A>
+          <SPAN ID="nav-docs">
+            
+          </SPAN>
+          
+          
+
+          <BR>
+
+          <A HREF="module-simplejson.html" TITLE="simplejson reference">
+            simplejson
+          </A>
+
+          
+            
+            <A HREF="module-simplejson.html">details</A>
+            
+            <A HREF="module-simplejson-index.html">
+              tree
+            </A>
+            
+          
+        </DIV>
+    </DIV>
+    
+    <DIV ID="main-content">
+  
+  <H1 CLASS="pudge-member-page-heading">
+    <TT>simplejson</TT>
+  </H1>
+  <H4 CLASS="pudge-member-page-subheading">
+    A simple, fast, extensible JSON encoder and decoder
+  </H4>
+  
+  <DIV ID="pudge-section-nav">
+  <UL>
+    <LI>
+      
+      <SPAN CLASS="pudge-missing-section-link">
+        Attributes
+      </SPAN>
+    </LI><LI>
+      <A HREF="#functions" CLASS="pudge-section-link">
+        Functions (4)
+      </A>
+      
+    </LI><LI>
+      <A HREF="#classes" CLASS="pudge-section-link">
+        Classes (2)
+      </A>
+      
+    </LI><LI>
+      
+      <SPAN CLASS="pudge-missing-section-link">
+        Modules
+      </SPAN>
+    </LI>
+    <LI>
+      <A HREF="module-simplejson-index.html" CLASS="pudge-section-link">
+        Index
+      </A>
+    </LI>
+    <LI>
+      <A HREF="simplejson/__init__.py.html" CLASS="pudge-section-link">
+        Source
+      </A>
+    </LI>
+  </UL>
+  </DIV>
+  <DIV STYLE="clear: left"></DIV>
+  <DIV CLASS="rst pudge-module-doc">
+    <P>JSON (JavaScript Object Notation) &lt;<A HREF="http://json.org" CLASS="reference">http://json.org</A>> is a subset of
+JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data
+interchange format.</P>
+<P>simplejson exposes an API familiar to uses of the standard library
+marshal and pickle modules.</P>
+<P>Encoding basic Python object hierarchies:</P>
+<PRE CLASS="literal-block">
+>>> import simplejson
+>>> simplejson.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
+'["foo", {"bar": ["baz", null, 1.0, 2]}]'
+>>> print simplejson.dumps("\"foo\bar")
+"\"foo\bar"
+>>> print simplejson.dumps(u'\u1234')
+"\u1234"
+>>> print simplejson.dumps('\\')
+"\\"
+>>> print simplejson.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True)
+{"a": 0, "b": 0, "c": 0}
+>>> from StringIO import StringIO
+>>> io = StringIO()
+>>> simplejson.dump(['streaming API'], io)
+>>> io.getvalue()
+'["streaming API"]'
+</PRE>
+<P>Compact encoding:</P>
+<PRE CLASS="literal-block">
+>>> import simplejson
+>>> simplejson.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',',':'))
+'[1,2,3,{"4":5,"6":7}]'
+</PRE>
+<P>Pretty printing:</P>
+<PRE CLASS="literal-block">
+>>> import simplejson
+>>> print simplejson.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4)
+{
+    "4": 5,
+    "6": 7
+}
+</PRE>
+<P>Decoding JSON:</P>
+<PRE CLASS="literal-block">
+>>> import simplejson
+>>> simplejson.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
+[u'foo', {u'bar': [u'baz', None, 1.0, 2]}]
+>>> simplejson.loads('"\\"foo\\bar"')
+u'"foo\x08ar'
+>>> from StringIO import StringIO
+>>> io = StringIO('["streaming API"]')
+>>> simplejson.load(io)
+[u'streaming API']
+</PRE>
+<P>Specializing JSON object decoding:</P>
+<PRE CLASS="literal-block">
+>>> import simplejson
+>>> def as_complex(dct):
+...     if '__complex__' in dct:
+...         return complex(dct['real'], dct['imag'])
+...     return dct
+...
+>>> simplejson.loads('{"__complex__": true, "real": 1, "imag": 2}',
+...     object_hook=as_complex)
+(1+2j)
+</PRE>
+<P>Extending JSONEncoder:</P>
+<PRE CLASS="literal-block">
+>>> import simplejson
+>>> class ComplexEncoder(simplejson.JSONEncoder):
+...     def default(self, obj):
+...         if isinstance(obj, complex):
+...             return [obj.real, obj.imag]
+...         return simplejson.JSONEncoder.default(self, obj)
+...
+>>> dumps(2 + 1j, cls=ComplexEncoder)
+'[2.0, 1.0]'
+>>> ComplexEncoder().encode(2 + 1j)
+'[2.0, 1.0]'
+>>> list(ComplexEncoder().iterencode(2 + 1j))
+['[', '2.0', ', ', '1.0', ']']
+</PRE>
+<P>Note that the JSON produced by this module's default settings
+is a subset of YAML, so it may be used as a serializer for that as well.</P>
+
+  </DIV>
+  
+  <HR>
+  
+  
+    <A NAME="functions"></A>
+    <H2>Functions</H2>
+    <DIV CLASS="pudge-member routine ">
+    <A NAME="dump"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="module-simplejson.html#dump" CLASS="pudge-obj-link">dump</A>(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, encoding='utf-8', **kw)</TT>
+      <A HREF="simplejson/__init__.py.html?f=108&amp;l=164#108" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Serialize <TT CLASS="docutils literal"><SPAN CLASS="pre">obj</SPAN></TT> as a JSON formatted stream to <TT CLASS="docutils literal"><SPAN CLASS="pre">fp</SPAN></TT> (a
+<TT CLASS="docutils literal"><SPAN CLASS="pre">.write()</SPAN></TT>-supporting file-like object).
+    </P>
+    <P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">skipkeys</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">True</SPAN></TT> then <TT CLASS="docutils literal"><SPAN CLASS="pre">dict</SPAN></TT> keys that are not basic types
+(<TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">int</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">long</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">float</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">bool</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">None</SPAN></TT>)
+will be skipped instead of raising a <TT CLASS="docutils literal"><SPAN CLASS="pre">TypeError</SPAN></TT>.</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">ensure_ascii</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">False</SPAN></TT>, then the some chunks written to <TT CLASS="docutils literal"><SPAN CLASS="pre">fp</SPAN></TT>
+may be <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> instances, subject to normal Python <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT> to
+<TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> coercion rules. Unless <TT CLASS="docutils literal"><SPAN CLASS="pre">fp.write()</SPAN></TT> explicitly
+understands <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> (as in <TT CLASS="docutils literal"><SPAN CLASS="pre">codecs.getwriter()</SPAN></TT>) this is likely
+to cause an error.</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">check_circular</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">False</SPAN></TT>, then the circular reference check
+for container types will be skipped and a circular reference will
+result in an <TT CLASS="docutils literal"><SPAN CLASS="pre">OverflowError</SPAN></TT> (or worse).</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">allow_nan</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">False</SPAN></TT>, then it will be a <TT CLASS="docutils literal"><SPAN CLASS="pre">ValueError</SPAN></TT> to
+serialize out of range <TT CLASS="docutils literal"><SPAN CLASS="pre">float</SPAN></TT> values (<TT CLASS="docutils literal"><SPAN CLASS="pre">nan</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">inf</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">-inf</SPAN></TT>)
+in strict compliance of the JSON specification, instead of using the
+JavaScript equivalents (<TT CLASS="docutils literal"><SPAN CLASS="pre">NaN</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">Infinity</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">-Infinity</SPAN></TT>).</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">indent</SPAN></TT> 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. <TT CLASS="docutils literal"><SPAN CLASS="pre">None</SPAN></TT> is the most compact representation.</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">separators</SPAN></TT> is an <TT CLASS="docutils literal"><SPAN CLASS="pre">(item_separator,</SPAN> <SPAN CLASS="pre">dict_separator)</SPAN></TT> tuple
+then it will be used instead of the default <TT CLASS="docutils literal"><SPAN CLASS="pre">(',</SPAN> <SPAN CLASS="pre">',</SPAN> <SPAN CLASS="pre">':</SPAN> <SPAN CLASS="pre">')</SPAN></TT> separators.
+<TT CLASS="docutils literal"><SPAN CLASS="pre">(',',</SPAN> <SPAN CLASS="pre">':')</SPAN></TT> is the most compact JSON representation.</P>
+<P><TT CLASS="docutils literal"><SPAN CLASS="pre">encoding</SPAN></TT> is the character encoding for str instances, default is UTF-8.</P>
+<P>To use a custom <TT CLASS="docutils literal"><SPAN CLASS="pre">JSONEncoder</SPAN></TT> subclass (e.g. one that overrides the
+<TT CLASS="docutils literal"><SPAN CLASS="pre">.default()</SPAN></TT> method to serialize additional types), specify it with
+the <TT CLASS="docutils literal"><SPAN CLASS="pre">cls</SPAN></TT> kwarg.</P>
+
+  
+    </DIV>
+  </DIV><DIV CLASS="pudge-member routine ">
+    <A NAME="dumps"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="module-simplejson.html#dumps" CLASS="pudge-obj-link">dumps</A>(obj, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, encoding='utf-8', **kw)</TT>
+      <A HREF="simplejson/__init__.py.html?f=166&amp;l=217#166" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Serialize <TT CLASS="docutils literal"><SPAN CLASS="pre">obj</SPAN></TT> to a JSON formatted <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT>.
+    </P>
+    <P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">skipkeys</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">True</SPAN></TT> then <TT CLASS="docutils literal"><SPAN CLASS="pre">dict</SPAN></TT> keys that are not basic types
+(<TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">int</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">long</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">float</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">bool</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">None</SPAN></TT>)
+will be skipped instead of raising a <TT CLASS="docutils literal"><SPAN CLASS="pre">TypeError</SPAN></TT>.</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">ensure_ascii</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">False</SPAN></TT>, then the return value will be a
+<TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> instance subject to normal Python <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT> to <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT>
+coercion rules instead of being escaped to an ASCII <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT>.</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">check_circular</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">False</SPAN></TT>, then the circular reference check
+for container types will be skipped and a circular reference will
+result in an <TT CLASS="docutils literal"><SPAN CLASS="pre">OverflowError</SPAN></TT> (or worse).</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">allow_nan</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">False</SPAN></TT>, then it will be a <TT CLASS="docutils literal"><SPAN CLASS="pre">ValueError</SPAN></TT> to
+serialize out of range <TT CLASS="docutils literal"><SPAN CLASS="pre">float</SPAN></TT> values (<TT CLASS="docutils literal"><SPAN CLASS="pre">nan</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">inf</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">-inf</SPAN></TT>) in
+strict compliance of the JSON specification, instead of using the
+JavaScript equivalents (<TT CLASS="docutils literal"><SPAN CLASS="pre">NaN</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">Infinity</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">-Infinity</SPAN></TT>).</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">indent</SPAN></TT> 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. <TT CLASS="docutils literal"><SPAN CLASS="pre">None</SPAN></TT> is the most compact
+representation.</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">separators</SPAN></TT> is an <TT CLASS="docutils literal"><SPAN CLASS="pre">(item_separator,</SPAN> <SPAN CLASS="pre">dict_separator)</SPAN></TT> tuple
+then it will be used instead of the default <TT CLASS="docutils literal"><SPAN CLASS="pre">(',</SPAN> <SPAN CLASS="pre">',</SPAN> <SPAN CLASS="pre">':</SPAN> <SPAN CLASS="pre">')</SPAN></TT> separators.
+<TT CLASS="docutils literal"><SPAN CLASS="pre">(',',</SPAN> <SPAN CLASS="pre">':')</SPAN></TT> is the most compact JSON representation.</P>
+<P><TT CLASS="docutils literal"><SPAN CLASS="pre">encoding</SPAN></TT> is the character encoding for str instances, default is UTF-8.</P>
+<P>To use a custom <TT CLASS="docutils literal"><SPAN CLASS="pre">JSONEncoder</SPAN></TT> subclass (e.g. one that overrides the
+<TT CLASS="docutils literal"><SPAN CLASS="pre">.default()</SPAN></TT> method to serialize additional types), specify it with
+the <TT CLASS="docutils literal"><SPAN CLASS="pre">cls</SPAN></TT> kwarg.</P>
+
+  
+    </DIV>
+  </DIV><DIV CLASS="pudge-member routine ">
+    <A NAME="load"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="module-simplejson.html#load" CLASS="pudge-obj-link">load</A>(fp, encoding=None, cls=None, object_hook=None, **kw)</TT>
+      <A HREF="simplejson/__init__.py.html?f=220&amp;l=242#220" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Deserialize <TT CLASS="docutils literal"><SPAN CLASS="pre">fp</SPAN></TT> (a <TT CLASS="docutils literal"><SPAN CLASS="pre">.read()</SPAN></TT>-supporting file-like object containing
+a JSON document) to a Python object.
+    </P>
+    <P>If the contents of <TT CLASS="docutils literal"><SPAN CLASS="pre">fp</SPAN></TT> is encoded with an ASCII based encoding other
+than utf-8 (e.g. latin-1), then an appropriate <TT CLASS="docutils literal"><SPAN CLASS="pre">encoding</SPAN></TT> name must
+be specified. Encodings that are not ASCII based (such as UCS-2) are
+not allowed, and should be wrapped with
+<TT CLASS="docutils literal"><SPAN CLASS="pre">codecs.getreader(fp)(encoding)</SPAN></TT>, or simply decoded to a <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT>
+object and passed to <TT CLASS="docutils literal"><SPAN CLASS="pre">loads()</SPAN></TT></P>
+<P><TT CLASS="docutils literal"><SPAN CLASS="pre">object_hook</SPAN></TT> is an optional function that will be called with the
+result of any object literal decode (a <TT CLASS="docutils literal"><SPAN CLASS="pre">dict</SPAN></TT>). The return value of
+<TT CLASS="docutils literal"><SPAN CLASS="pre">object_hook</SPAN></TT> will be used instead of the <TT CLASS="docutils literal"><SPAN CLASS="pre">dict</SPAN></TT>. This feature
+can be used to implement custom decoders (e.g. JSON-RPC class hinting).</P>
+<P>To use a custom <TT CLASS="docutils literal"><SPAN CLASS="pre">JSONDecoder</SPAN></TT> subclass, specify it with the <TT CLASS="docutils literal"><SPAN CLASS="pre">cls</SPAN></TT>
+kwarg.</P>
+
+  
+    </DIV>
+  </DIV><DIV CLASS="pudge-member routine ">
+    <A NAME="loads"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="module-simplejson.html#loads" CLASS="pudge-obj-link">loads</A>(s, encoding=None, cls=None, object_hook=None, **kw)</TT>
+      <A HREF="simplejson/__init__.py.html?f=243&amp;l=268#243" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Deserialize <TT CLASS="docutils literal"><SPAN CLASS="pre">s</SPAN></TT> (a <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT> or <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> instance containing a JSON
+document) to a Python object.
+    </P>
+    <P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">s</SPAN></TT> is a <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT> instance and is encoded with an ASCII based encoding
+other than utf-8 (e.g. latin-1) then an appropriate <TT CLASS="docutils literal"><SPAN CLASS="pre">encoding</SPAN></TT> name
+must be specified. Encodings that are not ASCII based (such as UCS-2)
+are not allowed and should be decoded to <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> first.</P>
+<P><TT CLASS="docutils literal"><SPAN CLASS="pre">object_hook</SPAN></TT> is an optional function that will be called with the
+result of any object literal decode (a <TT CLASS="docutils literal"><SPAN CLASS="pre">dict</SPAN></TT>). The return value of
+<TT CLASS="docutils literal"><SPAN CLASS="pre">object_hook</SPAN></TT> will be used instead of the <TT CLASS="docutils literal"><SPAN CLASS="pre">dict</SPAN></TT>. This feature
+can be used to implement custom decoders (e.g. JSON-RPC class hinting).</P>
+<P>To use a custom <TT CLASS="docutils literal"><SPAN CLASS="pre">JSONDecoder</SPAN></TT> subclass, specify it with the <TT CLASS="docutils literal"><SPAN CLASS="pre">cls</SPAN></TT>
+kwarg.</P>
+
+  
+    </DIV>
+  </DIV>
+    
+  
+    <A NAME="classes"></A>
+    <H2>Classes</H2>
+    <DIV CLASS="pudge-member class alias">
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">C</SPAN>
+      <TT>
+        <A HREF="class-simplejson.JSONEncoder.html" CLASS="pudge-obj-link">JSONEncoder</A>(...)</TT>
+      <A HREF="simplejson/encoder.py.html?f=80&amp;l=370#80" CLASS="pudge-member-view-source" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Extensible JSON &lt;<A HREF="http://json.org" CLASS="reference">http://json.org</A>> encoder for Python data structures.
+    </P>
+    <P>Supports the following objects and types by default:</P>
+<TABLE BORDER="1" CLASS="docutils">
+<COLGROUP>
+<COL WIDTH="56%">
+<COL WIDTH="44%">
+</COLGROUP>
+<THEAD VALIGN="bottom">
+<TR><TH CLASS="head">Python</TH>
+<TH CLASS="head">JSON</TH>
+</TR>
+</THEAD>
+<TBODY VALIGN="top">
+<TR><TD>dict</TD>
+<TD>object</TD>
+</TR>
+<TR><TD>list, tuple</TD>
+<TD>array</TD>
+</TR>
+<TR><TD>str, unicode</TD>
+<TD>string</TD>
+</TR>
+<TR><TD>int, long, float</TD>
+<TD>number</TD>
+</TR>
+<TR><TD>True</TD>
+<TD>true</TD>
+</TR>
+<TR><TD>False</TD>
+<TD>false</TD>
+</TR>
+<TR><TD>None</TD>
+<TD>null</TD>
+</TR>
+</TBODY>
+</TABLE>
+<P>To extend this to recognize other objects, subclass and implement a
+<TT CLASS="docutils literal"><SPAN CLASS="pre">.default()</SPAN></TT> method with another method that returns a serializable
+object for <TT CLASS="docutils literal"><SPAN CLASS="pre">o</SPAN></TT> if possible, otherwise it should call the superclass
+implementation (to raise <TT CLASS="docutils literal"><SPAN CLASS="pre">TypeError</SPAN></TT>).</P>
+
+  
+      
+      <P CLASS="note">
+        This class contains <A HREF="class-simplejson.JSONEncoder.html#members">
+          5 members</A>.
+      </P>
+    </DIV>
+  </DIV><DIV CLASS="pudge-member class alias">
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">C</SPAN>
+      <TT>
+        <A HREF="class-simplejson.JSONDecoder.html" CLASS="pudge-obj-link">JSONDecoder</A>(...)</TT>
+      <A HREF="simplejson/decoder.py.html?f=196&amp;l=272#196" CLASS="pudge-member-view-source" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Simple JSON &lt;<A HREF="http://json.org" CLASS="reference">http://json.org</A>> decoder
+    </P>
+    <P>Performs the following translations in decoding:</P>
+<TABLE BORDER="1" CLASS="docutils">
+<COLGROUP>
+<COL WIDTH="44%">
+<COL WIDTH="56%">
+</COLGROUP>
+<THEAD VALIGN="bottom">
+<TR><TH CLASS="head">JSON</TH>
+<TH CLASS="head">Python</TH>
+</TR>
+</THEAD>
+<TBODY VALIGN="top">
+<TR><TD>object</TD>
+<TD>dict</TD>
+</TR>
+<TR><TD>array</TD>
+<TD>list</TD>
+</TR>
+<TR><TD>string</TD>
+<TD>unicode</TD>
+</TR>
+<TR><TD>number (int)</TD>
+<TD>int, long</TD>
+</TR>
+<TR><TD>number (real)</TD>
+<TD>float</TD>
+</TR>
+<TR><TD>true</TD>
+<TD>True</TD>
+</TR>
+<TR><TD>false</TD>
+<TD>False</TD>
+</TR>
+<TR><TD>null</TD>
+<TD>None</TD>
+</TR>
+</TBODY>
+</TABLE>
+<P>It also understands <TT CLASS="docutils literal"><SPAN CLASS="pre">NaN</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">Infinity</SPAN></TT>, and <TT CLASS="docutils literal"><SPAN CLASS="pre">-Infinity</SPAN></TT> as
+their corresponding <TT CLASS="docutils literal"><SPAN CLASS="pre">float</SPAN></TT> values, which is outside the JSON spec.</P>
+
+  
+      
+      <P CLASS="note">
+        This class contains <A HREF="class-simplejson.JSONDecoder.html#members">
+          4 members</A>.
+      </P>
+    </DIV>
+  </DIV>
+    
+  
+  
+  <P>
+    <SMALL>
+    
+    
+    See 
+    <A HREF="simplejson/__init__.py.html" TITLE="simplejson/__init__.py:0">the source</A>
+    for more information.
+    </SMALL>
+  </P>
+
+</DIV>
+    
+    <DIV ID="footer">
+      
+      <P ID="pudge">
+        Built with
+        <A HREF="http://lesscode.org/projects/pudge/">
+          Pudge/0.1.3</A>
+      </P>
+
+      
+    </DIV>
+    </DIV>
+  </BODY>
+
+</HTML>
\ No newline at end of file
diff --git a/src/simplejson/docs/layout.css b/src/simplejson/docs/layout.css
new file mode 100644 (file)
index 0000000..a45c58b
--- /dev/null
@@ -0,0 +1,208 @@
+@import url("pudge.css");
+
+/* Basic Layout 
+---------------------------------- */
+
+body { 
+  margin-left: 1em;
+  margin-right: 1em;
+  max-width: 50em;
+}
+body { 
+  font-size: .80em;
+  color: #111;
+}
+div#main-content { 
+  margin-left: 1em;
+  margin-right: 1em;
+  max-width: 47em;
+}
+
+/* Top Navigation
+----------------------------------- */
+
+div#top-nav { 
+  background: #373;
+  padding: .3em .3em;
+  margin: 0;
+  margin-bottom: 1.5em;
+  font-size: 90%;
+}
+div#top-nav #doc-title { 
+  font-size: 140%;
+  font-weight: bold;
+  margin: 0;
+  padding-top: .32em;
+  padding-right: 1em;
+  padding-left: .3em;
+  color: #9c9;
+  float: left;
+}
+div#top-nav a { 
+  color: #6a6;
+  text-decoration: none;
+}
+div#top-nav .online-navigation a:hover,
+div#top-nav h1 a 
+{ 
+  color: #9c9;
+}
+
+/* Footer
+----------------------------------- */
+
+div#footer { 
+  text-align: right;
+  margin-top: 1.5em;
+  border-top: 1px solid #373;
+  padding-top: .5em;
+  font-size: 80%;
+  color: #666;
+}
+div#footer a { 
+  color: #373;
+  text-decoration: none;
+}
+div#footer p { 
+  margin: .2em 1em; 
+}
+
+/* Basic Style
+----------------------------------- */
+h1, h2, h3, h4 { 
+  margin: 1em auto; 
+  font-family: 'Trebuchet MS', 'Verdana', Sans-serif;
+  color: #555;
+  font-weight: normal;
+}
+h1 { font-size: 200% }
+h2 { font-size: 170% }
+h3 { font-size: 150% }
+h4 { font-size: 120% }
+a:link { color: #060; font-weight: bold }
+a:visited { color: #060; text-decoration: none }
+hr { margin: auto 12px }
+pre { color: #036 }
+
+dl dt { 
+  font-style: italic;
+  margin-top: .5em;
+  font-weight: bold;
+  color: #555;
+}
+hr { 
+  color: #373;
+  background-color: #373;
+  height: 1px;
+  border: 0;
+  width: 100%;
+  margin: 2em 0; 
+}
+
+/* Pudge Elements
+--------------------------------- */
+
+h1.pudge-member-page-heading { 
+  font-size: 300%;
+  margin-top: .4em;
+  margin-bottom: .4em;
+}
+h4.pudge-member-page-subheading { 
+  font-size: 150%;
+  font-style: italic;
+  margin-top: -1.3em;
+  margin-left: 2em;
+  color: #999;
+}
+p.pudge-member-blurb { 
+  font-style: italic;
+  font-weight: bold;
+  font-size: 120%;
+  margin-top: 0.2em;
+  color: #6a6;
+}
+div.pudge-module-doc { 
+  max-width: 45em;
+}
+div.pudge-section { 
+  margin-left: 2em;
+  max-width: 45em;
+}
+p.pudge-member-blurb { 
+  font-style: italic;
+  font-weight: bold;
+  font-size: 120%;
+}
+
+/* Section Navigation 
+----------------------------------- */
+
+div#pudge-section-nav
+{
+  margin: 1em 0 1.5em 0;
+  padding: 0;
+  height: 20px;
+}
+
+div#pudge-section-nav ul { 
+  border: 0;
+  margin: 0;
+  padding: 0;
+  list-style-type: none;
+  text-align: center;
+  border-right: 1px solid #aaa;
+}
+div#pudge-section-nav ul li
+{
+  display: block;
+  float: left;
+  text-align: center;
+  padding: 0;
+  margin: 0;
+}
+
+div#pudge-section-nav ul li .pudge-section-link,
+div#pudge-section-nav ul li .pudge-missing-section-link
+{
+  background: #aaa;
+  width: 11em;
+  height: 1.8em;
+  border: 0;
+  border-right: 3px solid #fff;
+  padding: 0;
+  margin: 0 0 10px 0;
+  color: #ddd;
+  text-decoration: none;
+  display: block;
+  text-align: center;
+  font: normal 10px/18px "Lucida Grande", "Lucida Sans Unicode", verdana, lucida, sans-serif;
+  font-weight: bold;
+  cursor: hand;
+}
+
+div#pudge-section-nav ul li a:hover
+{
+  color: #fff;
+  background: #393;
+}
+
+div#pudge-section-nav ul li .pudge-section-link
+{
+  background: #373;
+  color: #9c9;
+}
+
+/* Module Lists
+----------------------------------- */
+dl.pudge-module-list dt { 
+  font-style: normal;
+  font-size: 110%;
+}
+dl.pudge-module-list dd { 
+  color: #555;
+}
+
+/* misc */
+pre, tt { 
+  font-size: 120%;
+}
diff --git a/src/simplejson/docs/module-index.html b/src/simplejson/docs/module-index.html
new file mode 100644 (file)
index 0000000..5e92fca
--- /dev/null
@@ -0,0 +1,111 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<HTML>
+  
+  <HEAD><META CONTENT="text/html; charset=utf-8" HTTP-EQUIV="Content-Type">
+    <TITLE>simplejson 1.7.1 -- Module Reference</TITLE>
+    <LINK HREF="layout.css" TYPE="text/css" REL="stylesheet">
+  </HEAD>
+  <BODY>
+    <DIV ID="page">
+      
+    <DIV ID="top-nav">
+        <H1 ID="doc-title"><A HREF="index.html" REL="index">simplejson 1.7.1</A></H1>
+        <DIV CLASS="online-navigation">
+          <A HREF="index.html" REL="index">index</A>
+          <SPAN ID="nav-docs">
+            
+          </SPAN>
+          
+          
+
+          <BR>
+
+          <A HREF="module-simplejson.html" TITLE="simplejson reference">
+            simplejson
+          </A>
+
+          
+        </DIV>
+    </DIV>
+    
+    <DIV ID="main-content">
+  
+  <H1 CLASS="pudge-member-page-heading">
+    simplejson 1.7.1
+  </H1>
+  <H4 CLASS="pudge-member-page-subheading">
+    Module Reference
+  </H4>
+  
+  <H2>Packages and Modules</H2>
+  
+  <DL CLASS="pudge-module-list">
+    
+    <DT><TT><A HREF="module-simplejson.html" CLASS="pudge-obj-link">
+        simplejson
+        </A></TT>
+    </DT>
+    <DD>
+      A simple, fast, extensible JSON encoder and decoder
+    </DD>
+    
+    <DT><TT><A HREF="module-simplejson.encoder.html" CLASS="pudge-obj-link">
+        simplejson.encoder
+        </A></TT>
+    </DT>
+    <DD>
+      Implementation of JSONEncoder
+    </DD>
+    
+    <DT><TT><A HREF="module-simplejson.jsonfilter.html" CLASS="pudge-obj-link">
+        simplejson.jsonfilter
+        </A></TT>
+    </DT>
+    
+    
+    <DT><TT><A HREF="module-simplejson.tests.html" CLASS="pudge-obj-link">
+        simplejson.tests
+        </A></TT>
+    </DT>
+    
+    
+    <DT><TT><A HREF="module-simplejson.decoder.html" CLASS="pudge-obj-link">
+        simplejson.decoder
+        </A></TT>
+    </DT>
+    <DD>
+      Implementation of JSONDecoder
+    </DD>
+    
+    <DT><TT><A HREF="module-simplejson.scanner.html" CLASS="pudge-obj-link">
+        simplejson.scanner
+        </A></TT>
+    </DT>
+    <DD>
+      Iterator based sre token scanner
+    </DD>
+    
+    <DT><TT><A HREF="module-simplejson._speedups.html" CLASS="pudge-obj-link">
+        simplejson._speedups
+        </A></TT>
+    </DT>
+    
+    
+  </DL>
+  
+</DIV>
+    
+    <DIV ID="footer">
+      
+      <P ID="pudge">
+        Built with
+        <A HREF="http://lesscode.org/projects/pudge/">
+          Pudge/0.1.3</A>
+      </P>
+
+      
+    </DIV>
+    </DIV>
+  </BODY>
+
+</HTML>
\ No newline at end of file
diff --git a/src/simplejson/docs/module-simplejson-index.html b/src/simplejson/docs/module-simplejson-index.html
new file mode 100644 (file)
index 0000000..935e026
--- /dev/null
@@ -0,0 +1,127 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<HTML>
+  
+  <HEAD><META CONTENT="text/html; charset=utf-8" HTTP-EQUIV="Content-Type">
+    <TITLE>Index of simplejson module</TITLE>
+    <LINK HREF="layout.css" TYPE="text/css" REL="stylesheet">
+  </HEAD>
+  <BODY>
+    <DIV ID="page">
+      
+    <DIV ID="top-nav">
+        <H1 ID="doc-title"><A HREF="index.html" REL="index">simplejson 1.7.1</A></H1>
+        <DIV CLASS="online-navigation">
+          <A HREF="index.html" REL="index">index</A>
+          <SPAN ID="nav-docs">
+            
+          </SPAN>
+          
+          
+
+          <BR>
+
+          <A HREF="module-simplejson.html" TITLE="simplejson reference">
+            simplejson
+          </A>
+
+          
+            
+            <A HREF="module-simplejson.html">details</A>
+            
+            <A HREF="module-simplejson-index.html">
+              tree
+            </A>
+            
+          
+        </DIV>
+    </DIV>
+    
+    <DIV ID="main-content">
+  
+  <H1>Index of the <TT>simplejson</TT> module</H1>
+  
+  <UL CLASS="pudge-module-index">
+    <LI CLASS="module">
+    <SPAN CLASS="prefix">m</SPAN>
+    <A HREF="module-simplejson.html">
+      <TT>simplejson</TT>
+    </A>
+    <A HREF="simplejson/__init__.py.html">...</A>
+    <SMALL>
+      - <SPAN CLASS="rst">A simple, fast, extensible JSON encoder and decoder</SPAN>
+  </SMALL>
+    <UL>
+      
+      
+      
+      
+      
+      <LI CLASS="routine">
+    <SPAN CLASS="prefix">f</SPAN>
+    <A HREF="module-simplejson.html#load">
+      <TT>load</TT>
+    </A>
+    <A HREF="simplejson/__init__.py.html?f=220&amp;l=242#220">...</A>
+    <SMALL>
+      - <SPAN CLASS="rst">Deserialize <TT CLASS="docutils literal"><SPAN CLASS="pre">fp</SPAN></TT> (a <TT CLASS="docutils literal"><SPAN CLASS="pre">.read()</SPAN></TT>-supporting file-like object containing
+a JSON document) to a Python object.</SPAN>
+  </SMALL>
+    
+  </LI><LI CLASS="routine">
+    <SPAN CLASS="prefix">f</SPAN>
+    <A HREF="module-simplejson.html#dump">
+      <TT>dump</TT>
+    </A>
+    <A HREF="simplejson/__init__.py.html?f=108&amp;l=164#108">...</A>
+    <SMALL>
+      - <SPAN CLASS="rst">Serialize <TT CLASS="docutils literal"><SPAN CLASS="pre">obj</SPAN></TT> as a JSON formatted stream to <TT CLASS="docutils literal"><SPAN CLASS="pre">fp</SPAN></TT> (a
+<TT CLASS="docutils literal"><SPAN CLASS="pre">.write()</SPAN></TT>-supporting file-like object).</SPAN>
+  </SMALL>
+    
+  </LI><LI CLASS="routine">
+    <SPAN CLASS="prefix">f</SPAN>
+    <A HREF="module-simplejson.html#dumps">
+      <TT>dumps</TT>
+    </A>
+    <A HREF="simplejson/__init__.py.html?f=166&amp;l=217#166">...</A>
+    <SMALL>
+      - <SPAN CLASS="rst">Serialize <TT CLASS="docutils literal"><SPAN CLASS="pre">obj</SPAN></TT> to a JSON formatted <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT>.</SPAN>
+  </SMALL>
+    
+  </LI><LI CLASS="routine">
+    <SPAN CLASS="prefix">f</SPAN>
+    <A HREF="module-simplejson.html#loads">
+      <TT>loads</TT>
+    </A>
+    <A HREF="simplejson/__init__.py.html?f=243&amp;l=268#243">...</A>
+    <SMALL>
+      - <SPAN CLASS="rst">Deserialize <TT CLASS="docutils literal"><SPAN CLASS="pre">s</SPAN></TT> (a <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT> or <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> instance containing a JSON
+document) to a Python object.</SPAN>
+  </SMALL>
+    
+  </LI>
+      
+      
+      
+    </UL>
+  </LI>
+  </UL>
+  
+  
+  
+</DIV>
+    
+    <DIV ID="footer">
+      
+      <P ID="pudge">
+        Built with
+        <A HREF="http://lesscode.org/projects/pudge/">
+          Pudge/0.1.3</A>
+      </P>
+
+      
+    </DIV>
+    </DIV>
+  </BODY>
+
+</HTML>
\ No newline at end of file
diff --git a/src/simplejson/docs/module-simplejson.html b/src/simplejson/docs/module-simplejson.html
new file mode 100644 (file)
index 0000000..c142f3f
--- /dev/null
@@ -0,0 +1,455 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<HTML>
+  
+  <HEAD><META CONTENT="text/html; charset=utf-8" HTTP-EQUIV="Content-Type">
+    <TITLE>simplejson -- A simple, fast, extensible JSON encoder and decoder</TITLE>
+    <LINK HREF="layout.css" TYPE="text/css" REL="stylesheet">
+  </HEAD>
+  <BODY>
+    <DIV ID="page">
+      
+    <DIV ID="top-nav">
+        <H1 ID="doc-title"><A HREF="index.html" REL="index">simplejson 1.7.1</A></H1>
+        <DIV CLASS="online-navigation">
+          <A HREF="index.html" REL="index">index</A>
+          <SPAN ID="nav-docs">
+            
+          </SPAN>
+          
+          
+
+          <BR>
+
+          <A HREF="module-simplejson.html" TITLE="simplejson reference">
+            simplejson
+          </A>
+
+          
+            
+            <A HREF="module-simplejson.html">details</A>
+            
+            <A HREF="module-simplejson-index.html">
+              tree
+            </A>
+            
+          
+        </DIV>
+    </DIV>
+    
+    <DIV ID="main-content">
+  
+  <H1 CLASS="pudge-member-page-heading">
+    <TT>simplejson</TT>
+  </H1>
+  <H4 CLASS="pudge-member-page-subheading">
+    A simple, fast, extensible JSON encoder and decoder
+  </H4>
+  
+  <DIV ID="pudge-section-nav">
+  <UL>
+    <LI>
+      
+      <SPAN CLASS="pudge-missing-section-link">
+        Attributes
+      </SPAN>
+    </LI><LI>
+      <A HREF="#functions" CLASS="pudge-section-link">
+        Functions (4)
+      </A>
+      
+    </LI><LI>
+      <A HREF="#classes" CLASS="pudge-section-link">
+        Classes (2)
+      </A>
+      
+    </LI><LI>
+      
+      <SPAN CLASS="pudge-missing-section-link">
+        Modules
+      </SPAN>
+    </LI>
+    <LI>
+      <A HREF="module-simplejson-index.html" CLASS="pudge-section-link">
+        Index
+      </A>
+    </LI>
+    <LI>
+      <A HREF="simplejson/__init__.py.html" CLASS="pudge-section-link">
+        Source
+      </A>
+    </LI>
+  </UL>
+  </DIV>
+  <DIV STYLE="clear: left"></DIV>
+  <DIV CLASS="rst pudge-module-doc">
+    <P>JSON (JavaScript Object Notation) &lt;<A HREF="http://json.org" CLASS="reference">http://json.org</A>> is a subset of
+JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data
+interchange format.</P>
+<P>simplejson exposes an API familiar to uses of the standard library
+marshal and pickle modules.</P>
+<P>Encoding basic Python object hierarchies:</P>
+<PRE CLASS="literal-block">
+>>> import simplejson
+>>> simplejson.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
+'["foo", {"bar": ["baz", null, 1.0, 2]}]'
+>>> print simplejson.dumps("\"foo\bar")
+"\"foo\bar"
+>>> print simplejson.dumps(u'\u1234')
+"\u1234"
+>>> print simplejson.dumps('\\')
+"\\"
+>>> print simplejson.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True)
+{"a": 0, "b": 0, "c": 0}
+>>> from StringIO import StringIO
+>>> io = StringIO()
+>>> simplejson.dump(['streaming API'], io)
+>>> io.getvalue()
+'["streaming API"]'
+</PRE>
+<P>Compact encoding:</P>
+<PRE CLASS="literal-block">
+>>> import simplejson
+>>> simplejson.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',',':'))
+'[1,2,3,{"4":5,"6":7}]'
+</PRE>
+<P>Pretty printing:</P>
+<PRE CLASS="literal-block">
+>>> import simplejson
+>>> print simplejson.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4)
+{
+    "4": 5,
+    "6": 7
+}
+</PRE>
+<P>Decoding JSON:</P>
+<PRE CLASS="literal-block">
+>>> import simplejson
+>>> simplejson.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
+[u'foo', {u'bar': [u'baz', None, 1.0, 2]}]
+>>> simplejson.loads('"\\"foo\\bar"')
+u'"foo\x08ar'
+>>> from StringIO import StringIO
+>>> io = StringIO('["streaming API"]')
+>>> simplejson.load(io)
+[u'streaming API']
+</PRE>
+<P>Specializing JSON object decoding:</P>
+<PRE CLASS="literal-block">
+>>> import simplejson
+>>> def as_complex(dct):
+...     if '__complex__' in dct:
+...         return complex(dct['real'], dct['imag'])
+...     return dct
+...
+>>> simplejson.loads('{"__complex__": true, "real": 1, "imag": 2}',
+...     object_hook=as_complex)
+(1+2j)
+</PRE>
+<P>Extending JSONEncoder:</P>
+<PRE CLASS="literal-block">
+>>> import simplejson
+>>> class ComplexEncoder(simplejson.JSONEncoder):
+...     def default(self, obj):
+...         if isinstance(obj, complex):
+...             return [obj.real, obj.imag]
+...         return simplejson.JSONEncoder.default(self, obj)
+...
+>>> dumps(2 + 1j, cls=ComplexEncoder)
+'[2.0, 1.0]'
+>>> ComplexEncoder().encode(2 + 1j)
+'[2.0, 1.0]'
+>>> list(ComplexEncoder().iterencode(2 + 1j))
+['[', '2.0', ', ', '1.0', ']']
+</PRE>
+<P>Note that the JSON produced by this module's default settings
+is a subset of YAML, so it may be used as a serializer for that as well.</P>
+
+  </DIV>
+  
+  <HR>
+  
+  
+    <A NAME="functions"></A>
+    <H2>Functions</H2>
+    <DIV CLASS="pudge-member routine ">
+    <A NAME="dump"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="module-simplejson.html#dump" CLASS="pudge-obj-link">dump</A>(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, encoding='utf-8', **kw)</TT>
+      <A HREF="simplejson/__init__.py.html?f=108&amp;l=164#108" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Serialize <TT CLASS="docutils literal"><SPAN CLASS="pre">obj</SPAN></TT> as a JSON formatted stream to <TT CLASS="docutils literal"><SPAN CLASS="pre">fp</SPAN></TT> (a
+<TT CLASS="docutils literal"><SPAN CLASS="pre">.write()</SPAN></TT>-supporting file-like object).
+    </P>
+    <P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">skipkeys</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">True</SPAN></TT> then <TT CLASS="docutils literal"><SPAN CLASS="pre">dict</SPAN></TT> keys that are not basic types
+(<TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">int</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">long</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">float</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">bool</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">None</SPAN></TT>)
+will be skipped instead of raising a <TT CLASS="docutils literal"><SPAN CLASS="pre">TypeError</SPAN></TT>.</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">ensure_ascii</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">False</SPAN></TT>, then the some chunks written to <TT CLASS="docutils literal"><SPAN CLASS="pre">fp</SPAN></TT>
+may be <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> instances, subject to normal Python <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT> to
+<TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> coercion rules. Unless <TT CLASS="docutils literal"><SPAN CLASS="pre">fp.write()</SPAN></TT> explicitly
+understands <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> (as in <TT CLASS="docutils literal"><SPAN CLASS="pre">codecs.getwriter()</SPAN></TT>) this is likely
+to cause an error.</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">check_circular</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">False</SPAN></TT>, then the circular reference check
+for container types will be skipped and a circular reference will
+result in an <TT CLASS="docutils literal"><SPAN CLASS="pre">OverflowError</SPAN></TT> (or worse).</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">allow_nan</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">False</SPAN></TT>, then it will be a <TT CLASS="docutils literal"><SPAN CLASS="pre">ValueError</SPAN></TT> to
+serialize out of range <TT CLASS="docutils literal"><SPAN CLASS="pre">float</SPAN></TT> values (<TT CLASS="docutils literal"><SPAN CLASS="pre">nan</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">inf</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">-inf</SPAN></TT>)
+in strict compliance of the JSON specification, instead of using the
+JavaScript equivalents (<TT CLASS="docutils literal"><SPAN CLASS="pre">NaN</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">Infinity</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">-Infinity</SPAN></TT>).</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">indent</SPAN></TT> 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. <TT CLASS="docutils literal"><SPAN CLASS="pre">None</SPAN></TT> is the most compact representation.</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">separators</SPAN></TT> is an <TT CLASS="docutils literal"><SPAN CLASS="pre">(item_separator,</SPAN> <SPAN CLASS="pre">dict_separator)</SPAN></TT> tuple
+then it will be used instead of the default <TT CLASS="docutils literal"><SPAN CLASS="pre">(',</SPAN> <SPAN CLASS="pre">',</SPAN> <SPAN CLASS="pre">':</SPAN> <SPAN CLASS="pre">')</SPAN></TT> separators.
+<TT CLASS="docutils literal"><SPAN CLASS="pre">(',',</SPAN> <SPAN CLASS="pre">':')</SPAN></TT> is the most compact JSON representation.</P>
+<P><TT CLASS="docutils literal"><SPAN CLASS="pre">encoding</SPAN></TT> is the character encoding for str instances, default is UTF-8.</P>
+<P>To use a custom <TT CLASS="docutils literal"><SPAN CLASS="pre">JSONEncoder</SPAN></TT> subclass (e.g. one that overrides the
+<TT CLASS="docutils literal"><SPAN CLASS="pre">.default()</SPAN></TT> method to serialize additional types), specify it with
+the <TT CLASS="docutils literal"><SPAN CLASS="pre">cls</SPAN></TT> kwarg.</P>
+
+  
+    </DIV>
+  </DIV><DIV CLASS="pudge-member routine ">
+    <A NAME="dumps"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="module-simplejson.html#dumps" CLASS="pudge-obj-link">dumps</A>(obj, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, encoding='utf-8', **kw)</TT>
+      <A HREF="simplejson/__init__.py.html?f=166&amp;l=217#166" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Serialize <TT CLASS="docutils literal"><SPAN CLASS="pre">obj</SPAN></TT> to a JSON formatted <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT>.
+    </P>
+    <P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">skipkeys</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">True</SPAN></TT> then <TT CLASS="docutils literal"><SPAN CLASS="pre">dict</SPAN></TT> keys that are not basic types
+(<TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">int</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">long</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">float</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">bool</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">None</SPAN></TT>)
+will be skipped instead of raising a <TT CLASS="docutils literal"><SPAN CLASS="pre">TypeError</SPAN></TT>.</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">ensure_ascii</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">False</SPAN></TT>, then the return value will be a
+<TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> instance subject to normal Python <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT> to <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT>
+coercion rules instead of being escaped to an ASCII <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT>.</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">check_circular</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">False</SPAN></TT>, then the circular reference check
+for container types will be skipped and a circular reference will
+result in an <TT CLASS="docutils literal"><SPAN CLASS="pre">OverflowError</SPAN></TT> (or worse).</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">allow_nan</SPAN></TT> is <TT CLASS="docutils literal"><SPAN CLASS="pre">False</SPAN></TT>, then it will be a <TT CLASS="docutils literal"><SPAN CLASS="pre">ValueError</SPAN></TT> to
+serialize out of range <TT CLASS="docutils literal"><SPAN CLASS="pre">float</SPAN></TT> values (<TT CLASS="docutils literal"><SPAN CLASS="pre">nan</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">inf</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">-inf</SPAN></TT>) in
+strict compliance of the JSON specification, instead of using the
+JavaScript equivalents (<TT CLASS="docutils literal"><SPAN CLASS="pre">NaN</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">Infinity</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">-Infinity</SPAN></TT>).</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">indent</SPAN></TT> 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. <TT CLASS="docutils literal"><SPAN CLASS="pre">None</SPAN></TT> is the most compact
+representation.</P>
+<P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">separators</SPAN></TT> is an <TT CLASS="docutils literal"><SPAN CLASS="pre">(item_separator,</SPAN> <SPAN CLASS="pre">dict_separator)</SPAN></TT> tuple
+then it will be used instead of the default <TT CLASS="docutils literal"><SPAN CLASS="pre">(',</SPAN> <SPAN CLASS="pre">',</SPAN> <SPAN CLASS="pre">':</SPAN> <SPAN CLASS="pre">')</SPAN></TT> separators.
+<TT CLASS="docutils literal"><SPAN CLASS="pre">(',',</SPAN> <SPAN CLASS="pre">':')</SPAN></TT> is the most compact JSON representation.</P>
+<P><TT CLASS="docutils literal"><SPAN CLASS="pre">encoding</SPAN></TT> is the character encoding for str instances, default is UTF-8.</P>
+<P>To use a custom <TT CLASS="docutils literal"><SPAN CLASS="pre">JSONEncoder</SPAN></TT> subclass (e.g. one that overrides the
+<TT CLASS="docutils literal"><SPAN CLASS="pre">.default()</SPAN></TT> method to serialize additional types), specify it with
+the <TT CLASS="docutils literal"><SPAN CLASS="pre">cls</SPAN></TT> kwarg.</P>
+
+  
+    </DIV>
+  </DIV><DIV CLASS="pudge-member routine ">
+    <A NAME="load"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="module-simplejson.html#load" CLASS="pudge-obj-link">load</A>(fp, encoding=None, cls=None, object_hook=None, **kw)</TT>
+      <A HREF="simplejson/__init__.py.html?f=220&amp;l=242#220" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Deserialize <TT CLASS="docutils literal"><SPAN CLASS="pre">fp</SPAN></TT> (a <TT CLASS="docutils literal"><SPAN CLASS="pre">.read()</SPAN></TT>-supporting file-like object containing
+a JSON document) to a Python object.
+    </P>
+    <P>If the contents of <TT CLASS="docutils literal"><SPAN CLASS="pre">fp</SPAN></TT> is encoded with an ASCII based encoding other
+than utf-8 (e.g. latin-1), then an appropriate <TT CLASS="docutils literal"><SPAN CLASS="pre">encoding</SPAN></TT> name must
+be specified. Encodings that are not ASCII based (such as UCS-2) are
+not allowed, and should be wrapped with
+<TT CLASS="docutils literal"><SPAN CLASS="pre">codecs.getreader(fp)(encoding)</SPAN></TT>, or simply decoded to a <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT>
+object and passed to <TT CLASS="docutils literal"><SPAN CLASS="pre">loads()</SPAN></TT></P>
+<P><TT CLASS="docutils literal"><SPAN CLASS="pre">object_hook</SPAN></TT> is an optional function that will be called with the
+result of any object literal decode (a <TT CLASS="docutils literal"><SPAN CLASS="pre">dict</SPAN></TT>). The return value of
+<TT CLASS="docutils literal"><SPAN CLASS="pre">object_hook</SPAN></TT> will be used instead of the <TT CLASS="docutils literal"><SPAN CLASS="pre">dict</SPAN></TT>. This feature
+can be used to implement custom decoders (e.g. JSON-RPC class hinting).</P>
+<P>To use a custom <TT CLASS="docutils literal"><SPAN CLASS="pre">JSONDecoder</SPAN></TT> subclass, specify it with the <TT CLASS="docutils literal"><SPAN CLASS="pre">cls</SPAN></TT>
+kwarg.</P>
+
+  
+    </DIV>
+  </DIV><DIV CLASS="pudge-member routine ">
+    <A NAME="loads"></A>
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">f</SPAN>
+      <TT><A HREF="module-simplejson.html#loads" CLASS="pudge-obj-link">loads</A>(s, encoding=None, cls=None, object_hook=None, **kw)</TT>
+      <A HREF="simplejson/__init__.py.html?f=243&amp;l=268#243" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Deserialize <TT CLASS="docutils literal"><SPAN CLASS="pre">s</SPAN></TT> (a <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT> or <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> instance containing a JSON
+document) to a Python object.
+    </P>
+    <P>If <TT CLASS="docutils literal"><SPAN CLASS="pre">s</SPAN></TT> is a <TT CLASS="docutils literal"><SPAN CLASS="pre">str</SPAN></TT> instance and is encoded with an ASCII based encoding
+other than utf-8 (e.g. latin-1) then an appropriate <TT CLASS="docutils literal"><SPAN CLASS="pre">encoding</SPAN></TT> name
+must be specified. Encodings that are not ASCII based (such as UCS-2)
+are not allowed and should be decoded to <TT CLASS="docutils literal"><SPAN CLASS="pre">unicode</SPAN></TT> first.</P>
+<P><TT CLASS="docutils literal"><SPAN CLASS="pre">object_hook</SPAN></TT> is an optional function that will be called with the
+result of any object literal decode (a <TT CLASS="docutils literal"><SPAN CLASS="pre">dict</SPAN></TT>). The return value of
+<TT CLASS="docutils literal"><SPAN CLASS="pre">object_hook</SPAN></TT> will be used instead of the <TT CLASS="docutils literal"><SPAN CLASS="pre">dict</SPAN></TT>. This feature
+can be used to implement custom decoders (e.g. JSON-RPC class hinting).</P>
+<P>To use a custom <TT CLASS="docutils literal"><SPAN CLASS="pre">JSONDecoder</SPAN></TT> subclass, specify it with the <TT CLASS="docutils literal"><SPAN CLASS="pre">cls</SPAN></TT>
+kwarg.</P>
+
+  
+    </DIV>
+  </DIV>
+    
+  
+    <A NAME="classes"></A>
+    <H2>Classes</H2>
+    <DIV CLASS="pudge-member class alias">
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">C</SPAN>
+      <TT>
+        <A HREF="class-simplejson.JSONEncoder.html" CLASS="pudge-obj-link">JSONEncoder</A>(...)</TT>
+      <A HREF="simplejson/encoder.py.html?f=80&amp;l=370#80" CLASS="pudge-member-view-source" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Extensible JSON &lt;<A HREF="http://json.org" CLASS="reference">http://json.org</A>> encoder for Python data structures.
+    </P>
+    <P>Supports the following objects and types by default:</P>
+<TABLE BORDER="1" CLASS="docutils">
+<COLGROUP>
+<COL WIDTH="56%">
+<COL WIDTH="44%">
+</COLGROUP>
+<THEAD VALIGN="bottom">
+<TR><TH CLASS="head">Python</TH>
+<TH CLASS="head">JSON</TH>
+</TR>
+</THEAD>
+<TBODY VALIGN="top">
+<TR><TD>dict</TD>
+<TD>object</TD>
+</TR>
+<TR><TD>list, tuple</TD>
+<TD>array</TD>
+</TR>
+<TR><TD>str, unicode</TD>
+<TD>string</TD>
+</TR>
+<TR><TD>int, long, float</TD>
+<TD>number</TD>
+</TR>
+<TR><TD>True</TD>
+<TD>true</TD>
+</TR>
+<TR><TD>False</TD>
+<TD>false</TD>
+</TR>
+<TR><TD>None</TD>
+<TD>null</TD>
+</TR>
+</TBODY>
+</TABLE>
+<P>To extend this to recognize other objects, subclass and implement a
+<TT CLASS="docutils literal"><SPAN CLASS="pre">.default()</SPAN></TT> method with another method that returns a serializable
+object for <TT CLASS="docutils literal"><SPAN CLASS="pre">o</SPAN></TT> if possible, otherwise it should call the superclass
+implementation (to raise <TT CLASS="docutils literal"><SPAN CLASS="pre">TypeError</SPAN></TT>).</P>
+
+  
+      
+      <P CLASS="note">
+        This class contains <A HREF="class-simplejson.JSONEncoder.html#members">
+          5 members</A>.
+      </P>
+    </DIV>
+  </DIV><DIV CLASS="pudge-member class alias">
+    <H4 CLASS="pudge-member-name"><SPAN CLASS="prefix">C</SPAN>
+      <TT>
+        <A HREF="class-simplejson.JSONDecoder.html" CLASS="pudge-obj-link">JSONDecoder</A>(...)</TT>
+      <A HREF="simplejson/decoder.py.html?f=196&amp;l=272#196" CLASS="pudge-member-view-source" TITLE="View Source">...</A>
+    </H4>
+    <DIV CLASS="pudge-section rst">
+      
+    <P CLASS="pudge-member-blurb">
+      Simple JSON &lt;<A HREF="http://json.org" CLASS="reference">http://json.org</A>> decoder
+    </P>
+    <P>Performs the following translations in decoding:</P>
+<TABLE BORDER="1" CLASS="docutils">
+<COLGROUP>
+<COL WIDTH="44%">
+<COL WIDTH="56%">
+</COLGROUP>
+<THEAD VALIGN="bottom">
+<TR><TH CLASS="head">JSON</TH>
+<TH CLASS="head">Python</TH>
+</TR>
+</THEAD>
+<TBODY VALIGN="top">
+<TR><TD>object</TD>
+<TD>dict</TD>
+</TR>
+<TR><TD>array</TD>
+<TD>list</TD>
+</TR>
+<TR><TD>string</TD>
+<TD>unicode</TD>
+</TR>
+<TR><TD>number (int)</TD>
+<TD>int, long</TD>
+</TR>
+<TR><TD>number (real)</TD>
+<TD>float</TD>
+</TR>
+<TR><TD>true</TD>
+<TD>True</TD>
+</TR>
+<TR><TD>false</TD>
+<TD>False</TD>
+</TR>
+<TR><TD>null</TD>
+<TD>None</TD>
+</TR>
+</TBODY>
+</TABLE>
+<P>It also understands <TT CLASS="docutils literal"><SPAN CLASS="pre">NaN</SPAN></TT>, <TT CLASS="docutils literal"><SPAN CLASS="pre">Infinity</SPAN></TT>, and <TT CLASS="docutils literal"><SPAN CLASS="pre">-Infinity</SPAN></TT> as
+their corresponding <TT CLASS="docutils literal"><SPAN CLASS="pre">float</SPAN></TT> values, which is outside the JSON spec.</P>
+
+  
+      
+      <P CLASS="note">
+        This class contains <A HREF="class-simplejson.JSONDecoder.html#members">
+          4 members</A>.
+      </P>
+    </DIV>
+  </DIV>
+    
+  
+  
+  <P>
+    <SMALL>
+    
+    
+    See 
+    <A HREF="simplejson/__init__.py.html" TITLE="simplejson/__init__.py:0">the source</A>
+    for more information.
+    </SMALL>
+  </P>
+
+</DIV>
+    
+    <DIV ID="footer">
+      
+      <P ID="pudge">
+        Built with
+        <A HREF="http://lesscode.org/projects/pudge/">
+          Pudge/0.1.3</A>
+      </P>
+
+      
+    </DIV>
+    </DIV>
+  </BODY>
+
+</HTML>
\ No newline at end of file
diff --git a/src/simplejson/docs/pudge.css b/src/simplejson/docs/pudge.css
new file mode 100644 (file)
index 0000000..b370217
--- /dev/null
@@ -0,0 +1,60 @@
+/* Layout
+----------------------------------- */
+
+@import url("rst.css");
+
+/* Pudge Elements
+----------------------------------- */
+.note { font-size: 90% }
+h4.pudge-member-name { 
+  font-size: 110%;
+  margin-bottom: 0;
+}
+h4.pudge-member-name a.obj-link { 
+  font-weight: bold;
+  text-decoration: none;
+}
+h4.pudge-member-name .prefix { 
+  font-style: oblique;
+  padding-right: 6px;
+  font-weight: bold;
+  color: #c9c;
+}
+h1.pudge-member-page-heading { 
+  font-size: 250%;
+}
+h4.pudge-member-page-subheading { 
+  font-size: 150%;
+  font-style: italic;
+}
+h4.pudge-member-page-subheading p { 
+  display: inline;
+}
+div.pudge-member { 
+  margin-top: 1.5em;
+  margin-bottom: 1.5em;
+}
+ul.pudge-module-index { 
+  margin-left: 0;
+  padding-left: 0;
+}
+ul.pudge-module-index ul { 
+  padding-left: 1.5em;
+  margin-left: 0;
+}
+ul.pudge-module-index li { 
+  list-style-type: none;
+}
+ul.pudge-module-index .prefix { 
+  font-style: oblique;
+  padding-right: 6px;
+  font-size: 90%;
+  font-weight: bold;
+  color: purple;
+}
+ul.pudge-module-index a { 
+  text-decoration: none;
+}
+div.pudge-section { 
+  margin-left: 2em;
+}
\ No newline at end of file
diff --git a/src/simplejson/docs/rst.css b/src/simplejson/docs/rst.css
new file mode 100644 (file)
index 0000000..f48c723
--- /dev/null
@@ -0,0 +1,142 @@
+/* Headings
+   ------------------------------- */
+
+.rst h1 { font-size: 110% }
+.rst h2 { font-size: 100% }
+
+/*.rst-doc h1 { font-size: 200% }
+.rst-doc h2 { font-size: 140% }
+.rst-doc h3 { font-size: 110% }*/
+.rst-doc h1.title { font-size: 220% }
+.rst-doc h1 a, .rst-doc h2 a, .rst-doc h3 a { 
+  color: inherit ;
+  font-weight: inherit;
+  text-decoration: inherit;
+}
+
+/* Blockquotes
+   ------------------------------- */
+
+.rst blockquote,
+.rst-doc blockquote { 
+  font-style: italic;
+  font-family: Georgia, serif;
+  max-width: 30em;
+}
+
+/* Document Info
+   ------------------------------- */
+.rst-doc table.docinfo { 
+  margin: 2em 0 
+  width: 100%;
+}
+.rst-doc table.docinfo th { 
+  text-align: left ;
+  padding-right: 2em;
+  color: #555;
+}
+.rst-doc table.docinfo td { 
+  text-align: left
+}
+
+/* Field Lists 
+   ------------------------------- */
+
+.rst table.field-list, 
+.rst-doc table.field-list { 
+  border: 0;
+  margin-left: 0;
+}
+.rst table.field-list ul,
+.rst-doc table.field-list ul { 
+  margin-left: 0;
+}
+.rst-doc table.field-list ul { 
+  border: 0;
+  margin-left: 2em;
+  background: #fff;
+  color: #119;
+}
+
+/* Tables
+   ------------------------------- */
+
+.rst table.docutils,
+.rst-doc table.docutils { 
+  border: 0;
+}
+.rst table.docutils th,
+.rst-doc table.docutils th { 
+  border: 0;
+  background: #777;
+  color: #fff;
+  padding: 3px;
+}
+.rst table.docutils td,
+.rst-doc table.docutils td { 
+  border: 0;
+  border-bottom: 1px solid #ccc;
+  padding-bottom: 2px;
+}
+
+/* Contents and Back References
+   ------------------------------- */
+
+.rst-doc div.contents { 
+  margin: 2em inherit;
+}
+.rst-doc div.contents ul { 
+  margin-left: 0;
+  padding-left: 2em;
+  line-height: 150%;
+}
+.rst-doc div.contents ul li { 
+  font-weight: bold;
+  list-style-type: none;
+} 
+.rst-doc div.contents p.topic-title {
+  font-size: 160%;
+  font-weight: normal;
+  color: #555;
+  margin-top: .5em;
+}
+.rst-doc .contents .reference,
+.rst-doc .toc-backref { 
+  text-decoration: none;
+}
+
+/* Admonitions
+   ------------------------------- */
+
+.rst-doc div.admonition,
+.rst-doc div.warning,
+.rst-doc div.note { 
+  margin: 2.5em 6em;
+  padding: .6em 2.5em;
+  background: #ddf;
+  border: 2px solid #ccc;
+  font-family: Georgia, serif;
+  color: #333;
+}
+.rst-doc div.warning { 
+  background: #ff8;
+  border-color: #fe2;
+}
+.rst-doc div .admonition-title { 
+  font-weight: bold;
+  font-style: italic;
+  color: #223;
+  font-size: 110%;
+  font-family: sans-serif;
+}
+
+/* Misc
+   ------------------------------- */
+
+tt.literal { 
+  color: #333;
+}
+.footnote-reference { 
+  vertical-align: super;
+  font-size: 20%;
+}
\ No newline at end of file
diff --git a/src/simplejson/docs/simplejson/__init__.py.html b/src/simplejson/docs/simplejson/__init__.py.html
new file mode 100644 (file)
index 0000000..fb67bda
--- /dev/null
@@ -0,0 +1,357 @@
+<html><head><title>/Users/bob/src/simplejson/simplejson/__init__.py</title>
+        <script type="text/javascript"><!--
+        
+function show_line_range() {
+    var href = document.location.href;
+    if (href.indexOf('?') == -1) {
+        return;
+    }
+    var qs = href.substring(href.indexOf('?')+1);
+    if (qs.indexOf('#') >= 0) {
+        qs = qs.substring(0, qs.indexOf('#'));
+    }
+    var first = qs.match(/f=(\d+)/)[1];
+    var last = qs.match(/l=(\d+)/)[1];
+    if (! first || ! last) {
+        return;
+    }
+    var anchors = document.getElementsByTagName('A');
+    var container = document.createElement('DIV');
+    container.className = 'highlighted';
+    var children = [];
+    var start = null;
+    var parent = null;
+    var highlight = false;
+    for (var i = 0; i < anchors.length; i++) {
+        var el = anchors[i];
+        if (el.getAttribute('name') == first) {
+            start = el.previousSibling;
+            parent = el.parentNode;
+            highlight = true;
+        }
+        if (el.getAttribute('name') == last) {
+            break;
+        }
+        if (highlight) {
+            children[children.length] = el;
+            el = el.nextSibling;
+            while (el && el.tagName != 'A') {
+                children[children.length] = el;
+                el = el.nextSibling;
+            }
+        }
+    }
+    for (i=0; i<children.length; i++) {
+        container.appendChild(children[i]);
+    }
+    if (start) {
+        start.parentNode.insertBefore(container, start.nextSibling);
+    } else {
+        parent.insertBefore(container, parent.childNodes[0]);
+    }
+}
+
+        // --></script>
+        <style>
+        div.python {
+          color: #333
+        }
+        div.python a.lnum {
+          color: #555;
+          background-color: #eee;
+          border-right: 1px solid #999;
+          padding-right: 2px;
+          margin-right: 4px;
+        }
+        div.python span.comment { color: #933 }
+        div.python span.keyword { color: #a3e; font-weight: bold  }
+        div.python span.op { color: #c96 }
+        div.python span.string { color: #6a6 }
+        div.python span.name { }
+        div.python span.text { color: #333 }
+        div.highlighted { background-color: #ff9; border: 1px solid #009 }
+        </style></head><body onload="show_line_range()"><div class="python"><code><a class="lnum" href="#1" name="1">0001</a><span class="string">r"""</span><br />
+<a class="lnum" href="#2" name="2">0002</a><span class="string">A&#0160;simple,&#0160;fast,&#0160;extensible&#0160;JSON&#0160;encoder&#0160;and&#0160;decoder</span><br />
+<a class="lnum" href="#3" name="3">0003</a><span class="string"></span><br />
+<a class="lnum" href="#4" name="4">0004</a><span class="string">JSON&#0160;(JavaScript&#0160;Object&#0160;Notation)&#0160;&lt;http://json.org&gt;&#0160;is&#0160;a&#0160;subset&#0160;of</span><br />
+<a class="lnum" href="#5" name="5">0005</a><span class="string">JavaScript&#0160;syntax&#0160;(ECMA-262&#0160;3rd&#0160;edition)&#0160;used&#0160;as&#0160;a&#0160;lightweight&#0160;data</span><br />
+<a class="lnum" href="#6" name="6">0006</a><span class="string">interchange&#0160;format.</span><br />
+<a class="lnum" href="#7" name="7">0007</a><span class="string"></span><br />
+<a class="lnum" href="#8" name="8">0008</a><span class="string">simplejson&#0160;exposes&#0160;an&#0160;API&#0160;familiar&#0160;to&#0160;uses&#0160;of&#0160;the&#0160;standard&#0160;library</span><br />
+<a class="lnum" href="#9" name="9">0009</a><span class="string">marshal&#0160;and&#0160;pickle&#0160;modules.</span><br />
+<a class="lnum" href="#10" name="10">0010</a><span class="string"></span><br />
+<a class="lnum" href="#11" name="11">0011</a><span class="string">Encoding&#0160;basic&#0160;Python&#0160;object&#0160;hierarchies::</span><br />
+<a class="lnum" href="#12" name="12">0012</a><span class="string">&#0160;&#0160;&#0160;&#0160;</span><br />
+<a class="lnum" href="#13" name="13">0013</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;import&#0160;simplejson</span><br />
+<a class="lnum" href="#14" name="14">0014</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;simplejson.dumps(['foo',&#0160;{'bar':&#0160;('baz',&#0160;None,&#0160;1.0,&#0160;2)}])</span><br />
+<a class="lnum" href="#15" name="15">0015</a><span class="string">&#0160;&#0160;&#0160;&#0160;'["foo",&#0160;{"bar":&#0160;["baz",&#0160;null,&#0160;1.0,&#0160;2]}]'</span><br />
+<a class="lnum" href="#16" name="16">0016</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;print&#0160;simplejson.dumps("\"foo\bar")</span><br />
+<a class="lnum" href="#17" name="17">0017</a><span class="string">&#0160;&#0160;&#0160;&#0160;"\"foo\bar"</span><br />
+<a class="lnum" href="#18" name="18">0018</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;print&#0160;simplejson.dumps(u'\u1234')</span><br />
+<a class="lnum" href="#19" name="19">0019</a><span class="string">&#0160;&#0160;&#0160;&#0160;"\u1234"</span><br />
+<a class="lnum" href="#20" name="20">0020</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;print&#0160;simplejson.dumps('\\')</span><br />
+<a class="lnum" href="#21" name="21">0021</a><span class="string">&#0160;&#0160;&#0160;&#0160;"\\"</span><br />
+<a class="lnum" href="#22" name="22">0022</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;print&#0160;simplejson.dumps({"c":&#0160;0,&#0160;"b":&#0160;0,&#0160;"a":&#0160;0},&#0160;sort_keys=True)</span><br />
+<a class="lnum" href="#23" name="23">0023</a><span class="string">&#0160;&#0160;&#0160;&#0160;{"a":&#0160;0,&#0160;"b":&#0160;0,&#0160;"c":&#0160;0}</span><br />
+<a class="lnum" href="#24" name="24">0024</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;from&#0160;StringIO&#0160;import&#0160;StringIO</span><br />
+<a class="lnum" href="#25" name="25">0025</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;io&#0160;=&#0160;StringIO()</span><br />
+<a class="lnum" href="#26" name="26">0026</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;simplejson.dump(['streaming&#0160;API'],&#0160;io)</span><br />
+<a class="lnum" href="#27" name="27">0027</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;io.getvalue()</span><br />
+<a class="lnum" href="#28" name="28">0028</a><span class="string">&#0160;&#0160;&#0160;&#0160;'["streaming&#0160;API"]'</span><br />
+<a class="lnum" href="#29" name="29">0029</a><span class="string"></span><br />
+<a class="lnum" href="#30" name="30">0030</a><span class="string">Compact&#0160;encoding::</span><br />
+<a class="lnum" href="#31" name="31">0031</a><span class="string"></span><br />
+<a class="lnum" href="#32" name="32">0032</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;import&#0160;simplejson</span><br />
+<a class="lnum" href="#33" name="33">0033</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;simplejson.dumps([1,2,3,{'4':&#0160;5,&#0160;'6':&#0160;7}],&#0160;separators=(',',':'))</span><br />
+<a class="lnum" href="#34" name="34">0034</a><span class="string">&#0160;&#0160;&#0160;&#0160;'[1,2,3,{"4":5,"6":7}]'</span><br />
+<a class="lnum" href="#35" name="35">0035</a><span class="string"></span><br />
+<a class="lnum" href="#36" name="36">0036</a><span class="string">Pretty&#0160;printing::</span><br />
+<a class="lnum" href="#37" name="37">0037</a><span class="string"></span><br />
+<a class="lnum" href="#38" name="38">0038</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;import&#0160;simplejson</span><br />
+<a class="lnum" href="#39" name="39">0039</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;print&#0160;simplejson.dumps({'4':&#0160;5,&#0160;'6':&#0160;7},&#0160;sort_keys=True,&#0160;indent=4)</span><br />
+<a class="lnum" href="#40" name="40">0040</a><span class="string">&#0160;&#0160;&#0160;&#0160;{</span><br />
+<a class="lnum" href="#41" name="41">0041</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;"4":&#0160;5,&#0160;</span><br />
+<a class="lnum" href="#42" name="42">0042</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;"6":&#0160;7</span><br />
+<a class="lnum" href="#43" name="43">0043</a><span class="string">&#0160;&#0160;&#0160;&#0160;}</span><br />
+<a class="lnum" href="#44" name="44">0044</a><span class="string"></span><br />
+<a class="lnum" href="#45" name="45">0045</a><span class="string">Decoding&#0160;JSON::</span><br />
+<a class="lnum" href="#46" name="46">0046</a><span class="string">&#0160;&#0160;&#0160;&#0160;</span><br />
+<a class="lnum" href="#47" name="47">0047</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;import&#0160;simplejson</span><br />
+<a class="lnum" href="#48" name="48">0048</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;simplejson.loads('["foo",&#0160;{"bar":["baz",&#0160;null,&#0160;1.0,&#0160;2]}]')</span><br />
+<a class="lnum" href="#49" name="49">0049</a><span class="string">&#0160;&#0160;&#0160;&#0160;[u'foo',&#0160;{u'bar':&#0160;[u'baz',&#0160;None,&#0160;1.0,&#0160;2]}]</span><br />
+<a class="lnum" href="#50" name="50">0050</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;simplejson.loads('"\\"foo\\bar"')</span><br />
+<a class="lnum" href="#51" name="51">0051</a><span class="string">&#0160;&#0160;&#0160;&#0160;u'"foo\x08ar'</span><br />
+<a class="lnum" href="#52" name="52">0052</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;from&#0160;StringIO&#0160;import&#0160;StringIO</span><br />
+<a class="lnum" href="#53" name="53">0053</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;io&#0160;=&#0160;StringIO('["streaming&#0160;API"]')</span><br />
+<a class="lnum" href="#54" name="54">0054</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;simplejson.load(io)</span><br />
+<a class="lnum" href="#55" name="55">0055</a><span class="string">&#0160;&#0160;&#0160;&#0160;[u'streaming&#0160;API']</span><br />
+<a class="lnum" href="#56" name="56">0056</a><span class="string"></span><br />
+<a class="lnum" href="#57" name="57">0057</a><span class="string">Specializing&#0160;JSON&#0160;object&#0160;decoding::</span><br />
+<a class="lnum" href="#58" name="58">0058</a><span class="string"></span><br />
+<a class="lnum" href="#59" name="59">0059</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;import&#0160;simplejson</span><br />
+<a class="lnum" href="#60" name="60">0060</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;def&#0160;as_complex(dct):</span><br />
+<a class="lnum" href="#61" name="61">0061</a><span class="string">&#0160;&#0160;&#0160;&#0160;...&#0160;&#0160;&#0160;&#0160;&#0160;if&#0160;'__complex__'&#0160;in&#0160;dct:</span><br />
+<a class="lnum" href="#62" name="62">0062</a><span class="string">&#0160;&#0160;&#0160;&#0160;...&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;return&#0160;complex(dct['real'],&#0160;dct['imag'])</span><br />
+<a class="lnum" href="#63" name="63">0063</a><span class="string">&#0160;&#0160;&#0160;&#0160;...&#0160;&#0160;&#0160;&#0160;&#0160;return&#0160;dct</span><br />
+<a class="lnum" href="#64" name="64">0064</a><span class="string">&#0160;&#0160;&#0160;&#0160;...&#0160;</span><br />
+<a class="lnum" href="#65" name="65">0065</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;simplejson.loads('{"__complex__":&#0160;true,&#0160;"real":&#0160;1,&#0160;"imag":&#0160;2}',</span><br />
+<a class="lnum" href="#66" name="66">0066</a><span class="string">&#0160;&#0160;&#0160;&#0160;...&#0160;&#0160;&#0160;&#0160;&#0160;object_hook=as_complex)</span><br />
+<a class="lnum" href="#67" name="67">0067</a><span class="string">&#0160;&#0160;&#0160;&#0160;(1+2j)</span><br />
+<a class="lnum" href="#68" name="68">0068</a><span class="string"></span><br />
+<a class="lnum" href="#69" name="69">0069</a><span class="string">Extending&#0160;JSONEncoder::</span><br />
+<a class="lnum" href="#70" name="70">0070</a><span class="string">&#0160;&#0160;&#0160;&#0160;</span><br />
+<a class="lnum" href="#71" name="71">0071</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;import&#0160;simplejson</span><br />
+<a class="lnum" href="#72" name="72">0072</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;class&#0160;ComplexEncoder(simplejson.JSONEncoder):</span><br />
+<a class="lnum" href="#73" name="73">0073</a><span class="string">&#0160;&#0160;&#0160;&#0160;...&#0160;&#0160;&#0160;&#0160;&#0160;def&#0160;default(self,&#0160;obj):</span><br />
+<a class="lnum" href="#74" name="74">0074</a><span class="string">&#0160;&#0160;&#0160;&#0160;...&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;if&#0160;isinstance(obj,&#0160;complex):</span><br />
+<a class="lnum" href="#75" name="75">0075</a><span class="string">&#0160;&#0160;&#0160;&#0160;...&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;return&#0160;[obj.real,&#0160;obj.imag]</span><br />
+<a class="lnum" href="#76" name="76">0076</a><span class="string">&#0160;&#0160;&#0160;&#0160;...&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;return&#0160;simplejson.JSONEncoder.default(self,&#0160;obj)</span><br />
+<a class="lnum" href="#77" name="77">0077</a><span class="string">&#0160;&#0160;&#0160;&#0160;...&#0160;</span><br />
+<a class="lnum" href="#78" name="78">0078</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;dumps(2&#0160;+&#0160;1j,&#0160;cls=ComplexEncoder)</span><br />
+<a class="lnum" href="#79" name="79">0079</a><span class="string">&#0160;&#0160;&#0160;&#0160;'[2.0,&#0160;1.0]'</span><br />
+<a class="lnum" href="#80" name="80">0080</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;ComplexEncoder().encode(2&#0160;+&#0160;1j)</span><br />
+<a class="lnum" href="#81" name="81">0081</a><span class="string">&#0160;&#0160;&#0160;&#0160;'[2.0,&#0160;1.0]'</span><br />
+<a class="lnum" href="#82" name="82">0082</a><span class="string">&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;list(ComplexEncoder().iterencode(2&#0160;+&#0160;1j))</span><br />
+<a class="lnum" href="#83" name="83">0083</a><span class="string">&#0160;&#0160;&#0160;&#0160;['[',&#0160;'2.0',&#0160;',&#0160;',&#0160;'1.0',&#0160;']']</span><br />
+<a class="lnum" href="#84" name="84">0084</a><span class="string">&#0160;&#0160;&#0160;&#0160;</span><br />
+<a class="lnum" href="#85" name="85">0085</a><span class="string"></span><br />
+<a class="lnum" href="#86" name="86">0086</a><span class="string">Note&#0160;that&#0160;the&#0160;JSON&#0160;produced&#0160;by&#0160;this&#0160;module's&#0160;default&#0160;settings</span><br />
+<a class="lnum" href="#87" name="87">0087</a><span class="string">is&#0160;a&#0160;subset&#0160;of&#0160;YAML,&#0160;so&#0160;it&#0160;may&#0160;be&#0160;used&#0160;as&#0160;a&#0160;serializer&#0160;for&#0160;that&#0160;as&#0160;well.</span><br />
+<a class="lnum" href="#88" name="88">0088</a><span class="string">"""</span><br />
+<a class="lnum" href="#89" name="89">0089</a><span class="name">__version__</span>&#0160;<span class="op">=</span>&#0160;<span class="string">'1.7.1'</span><br />
+<a class="lnum" href="#90" name="90">0090</a><span class="name">__all__</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><br />
+<a class="lnum" href="#91" name="91">0091</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'dump'</span><span class="op">,</span>&#0160;<span class="string">'dumps'</span><span class="op">,</span>&#0160;<span class="string">'load'</span><span class="op">,</span>&#0160;<span class="string">'loads'</span><span class="op">,</span><br />
+<a class="lnum" href="#92" name="92">0092</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'JSONDecoder'</span><span class="op">,</span>&#0160;<span class="string">'JSONEncoder'</span><span class="op">,</span><br />
+<a class="lnum" href="#93" name="93">0093</a><span class="op">]</span><br />
+<a class="lnum" href="#94" name="94">0094</a><br />
+<a class="lnum" href="#95" name="95">0095</a><span class="keyword">from</span>&#0160;<span class="name">decoder</span>&#0160;<span class="keyword">import</span>&#0160;<span class="name">JSONDecoder</span><br />
+<a class="lnum" href="#96" name="96">0096</a><span class="keyword">from</span>&#0160;<span class="name">encoder</span>&#0160;<span class="keyword">import</span>&#0160;<span class="name">JSONEncoder</span><br />
+<a class="lnum" href="#97" name="97">0097</a><br />
+<a class="lnum" href="#98" name="98">0098</a><span class="name">_default_encoder</span>&#0160;<span class="op">=</span>&#0160;<span class="name">JSONEncoder</span><span class="op">(</span><br />
+<a class="lnum" href="#99" name="99">0099</a>&#0160;&#0160;&#0160;&#0160;<span class="name">skipkeys</span><span class="op">=</span><span class="name">False</span><span class="op">,</span><br />
+<a class="lnum" href="#100" name="100">0100</a>&#0160;&#0160;&#0160;&#0160;<span class="name">ensure_ascii</span><span class="op">=</span><span class="name">True</span><span class="op">,</span><br />
+<a class="lnum" href="#101" name="101">0101</a>&#0160;&#0160;&#0160;&#0160;<span class="name">check_circular</span><span class="op">=</span><span class="name">True</span><span class="op">,</span><br />
+<a class="lnum" href="#102" name="102">0102</a>&#0160;&#0160;&#0160;&#0160;<span class="name">allow_nan</span><span class="op">=</span><span class="name">True</span><span class="op">,</span><br />
+<a class="lnum" href="#103" name="103">0103</a>&#0160;&#0160;&#0160;&#0160;<span class="name">indent</span><span class="op">=</span><span class="name">None</span><span class="op">,</span><br />
+<a class="lnum" href="#104" name="104">0104</a>&#0160;&#0160;&#0160;&#0160;<span class="name">separators</span><span class="op">=</span><span class="name">None</span><span class="op">,</span><br />
+<a class="lnum" href="#105" name="105">0105</a>&#0160;&#0160;&#0160;&#0160;<span class="name">encoding</span><span class="op">=</span><span class="string">'utf-8'</span><br />
+<a class="lnum" href="#106" name="106">0106</a><span class="op">)</span><br />
+<a class="lnum" href="#107" name="107">0107</a><br />
+<a class="lnum" href="#108" name="108">0108</a><span class="keyword">def</span>&#0160;<span class="name">dump</span><span class="op">(</span><span class="name">obj</span><span class="op">,</span>&#0160;<span class="name">fp</span><span class="op">,</span>&#0160;<span class="name">skipkeys</span><span class="op">=</span><span class="name">False</span><span class="op">,</span>&#0160;<span class="name">ensure_ascii</span><span class="op">=</span><span class="name">True</span><span class="op">,</span>&#0160;<span class="name">check_circular</span><span class="op">=</span><span class="name">True</span><span class="op">,</span><br />
+<a class="lnum" href="#109" name="109">0109</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">allow_nan</span><span class="op">=</span><span class="name">True</span><span class="op">,</span>&#0160;<span class="name">cls</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="name">indent</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="name">separators</span><span class="op">=</span><span class="name">None</span><span class="op">,</span><br />
+<a class="lnum" href="#110" name="110">0110</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">encoding</span><span class="op">=</span><span class="string">'utf-8'</span><span class="op">,</span>&#0160;<span class="op">**</span><span class="name">kw</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#111" name="111">0111</a>&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#112" name="112">0112</a><span class="string">&#0160;&#0160;&#0160;&#0160;Serialize&#0160;``obj``&#0160;as&#0160;a&#0160;JSON&#0160;formatted&#0160;stream&#0160;to&#0160;``fp``&#0160;(a</span><br />
+<a class="lnum" href="#113" name="113">0113</a><span class="string">&#0160;&#0160;&#0160;&#0160;``.write()``-supporting&#0160;file-like&#0160;object).</span><br />
+<a class="lnum" href="#114" name="114">0114</a><span class="string"></span><br />
+<a class="lnum" href="#115" name="115">0115</a><span class="string">&#0160;&#0160;&#0160;&#0160;If&#0160;``skipkeys``&#0160;is&#0160;``True``&#0160;then&#0160;``dict``&#0160;keys&#0160;that&#0160;are&#0160;not&#0160;basic&#0160;types</span><br />
+<a class="lnum" href="#116" name="116">0116</a><span class="string">&#0160;&#0160;&#0160;&#0160;(``str``,&#0160;``unicode``,&#0160;``int``,&#0160;``long``,&#0160;``float``,&#0160;``bool``,&#0160;``None``)&#0160;</span><br />
+<a class="lnum" href="#117" name="117">0117</a><span class="string">&#0160;&#0160;&#0160;&#0160;will&#0160;be&#0160;skipped&#0160;instead&#0160;of&#0160;raising&#0160;a&#0160;``TypeError``.</span><br />
+<a class="lnum" href="#118" name="118">0118</a><span class="string"></span><br />
+<a class="lnum" href="#119" name="119">0119</a><span class="string">&#0160;&#0160;&#0160;&#0160;If&#0160;``ensure_ascii``&#0160;is&#0160;``False``,&#0160;then&#0160;the&#0160;some&#0160;chunks&#0160;written&#0160;to&#0160;``fp``</span><br />
+<a class="lnum" href="#120" name="120">0120</a><span class="string">&#0160;&#0160;&#0160;&#0160;may&#0160;be&#0160;``unicode``&#0160;instances,&#0160;subject&#0160;to&#0160;normal&#0160;Python&#0160;``str``&#0160;to</span><br />
+<a class="lnum" href="#121" name="121">0121</a><span class="string">&#0160;&#0160;&#0160;&#0160;``unicode``&#0160;coercion&#0160;rules.&#0160;Unless&#0160;``fp.write()``&#0160;explicitly</span><br />
+<a class="lnum" href="#122" name="122">0122</a><span class="string">&#0160;&#0160;&#0160;&#0160;understands&#0160;``unicode``&#0160;(as&#0160;in&#0160;``codecs.getwriter()``)&#0160;this&#0160;is&#0160;likely</span><br />
+<a class="lnum" href="#123" name="123">0123</a><span class="string">&#0160;&#0160;&#0160;&#0160;to&#0160;cause&#0160;an&#0160;error.</span><br />
+<a class="lnum" href="#124" name="124">0124</a><span class="string"></span><br />
+<a class="lnum" href="#125" name="125">0125</a><span class="string">&#0160;&#0160;&#0160;&#0160;If&#0160;``check_circular``&#0160;is&#0160;``False``,&#0160;then&#0160;the&#0160;circular&#0160;reference&#0160;check</span><br />
+<a class="lnum" href="#126" name="126">0126</a><span class="string">&#0160;&#0160;&#0160;&#0160;for&#0160;container&#0160;types&#0160;will&#0160;be&#0160;skipped&#0160;and&#0160;a&#0160;circular&#0160;reference&#0160;will</span><br />
+<a class="lnum" href="#127" name="127">0127</a><span class="string">&#0160;&#0160;&#0160;&#0160;result&#0160;in&#0160;an&#0160;``OverflowError``&#0160;(or&#0160;worse).</span><br />
+<a class="lnum" href="#128" name="128">0128</a><span class="string"></span><br />
+<a class="lnum" href="#129" name="129">0129</a><span class="string">&#0160;&#0160;&#0160;&#0160;If&#0160;``allow_nan``&#0160;is&#0160;``False``,&#0160;then&#0160;it&#0160;will&#0160;be&#0160;a&#0160;``ValueError``&#0160;to</span><br />
+<a class="lnum" href="#130" name="130">0130</a><span class="string">&#0160;&#0160;&#0160;&#0160;serialize&#0160;out&#0160;of&#0160;range&#0160;``float``&#0160;values&#0160;(``nan``,&#0160;``inf``,&#0160;``-inf``)</span><br />
+<a class="lnum" href="#131" name="131">0131</a><span class="string">&#0160;&#0160;&#0160;&#0160;in&#0160;strict&#0160;compliance&#0160;of&#0160;the&#0160;JSON&#0160;specification,&#0160;instead&#0160;of&#0160;using&#0160;the</span><br />
+<a class="lnum" href="#132" name="132">0132</a><span class="string">&#0160;&#0160;&#0160;&#0160;JavaScript&#0160;equivalents&#0160;(``NaN``,&#0160;``Infinity``,&#0160;``-Infinity``).</span><br />
+<a class="lnum" href="#133" name="133">0133</a><span class="string"></span><br />
+<a class="lnum" href="#134" name="134">0134</a><span class="string">&#0160;&#0160;&#0160;&#0160;If&#0160;``indent``&#0160;is&#0160;a&#0160;non-negative&#0160;integer,&#0160;then&#0160;JSON&#0160;array&#0160;elements&#0160;and&#0160;object</span><br />
+<a class="lnum" href="#135" name="135">0135</a><span class="string">&#0160;&#0160;&#0160;&#0160;members&#0160;will&#0160;be&#0160;pretty-printed&#0160;with&#0160;that&#0160;indent&#0160;level.&#0160;An&#0160;indent&#0160;level</span><br />
+<a class="lnum" href="#136" name="136">0136</a><span class="string">&#0160;&#0160;&#0160;&#0160;of&#0160;0&#0160;will&#0160;only&#0160;insert&#0160;newlines.&#0160;``None``&#0160;is&#0160;the&#0160;most&#0160;compact&#0160;representation.</span><br />
+<a class="lnum" href="#137" name="137">0137</a><span class="string"></span><br />
+<a class="lnum" href="#138" name="138">0138</a><span class="string">&#0160;&#0160;&#0160;&#0160;If&#0160;``separators``&#0160;is&#0160;an&#0160;``(item_separator,&#0160;dict_separator)``&#0160;tuple</span><br />
+<a class="lnum" href="#139" name="139">0139</a><span class="string">&#0160;&#0160;&#0160;&#0160;then&#0160;it&#0160;will&#0160;be&#0160;used&#0160;instead&#0160;of&#0160;the&#0160;default&#0160;``(',&#0160;',&#0160;':&#0160;')``&#0160;separators.</span><br />
+<a class="lnum" href="#140" name="140">0140</a><span class="string">&#0160;&#0160;&#0160;&#0160;``(',',&#0160;':')``&#0160;is&#0160;the&#0160;most&#0160;compact&#0160;JSON&#0160;representation.</span><br />
+<a class="lnum" href="#141" name="141">0141</a><span class="string"></span><br />
+<a class="lnum" href="#142" name="142">0142</a><span class="string">&#0160;&#0160;&#0160;&#0160;``encoding``&#0160;is&#0160;the&#0160;character&#0160;encoding&#0160;for&#0160;str&#0160;instances,&#0160;default&#0160;is&#0160;UTF-8.</span><br />
+<a class="lnum" href="#143" name="143">0143</a><span class="string"></span><br />
+<a class="lnum" href="#144" name="144">0144</a><span class="string">&#0160;&#0160;&#0160;&#0160;To&#0160;use&#0160;a&#0160;custom&#0160;``JSONEncoder``&#0160;subclass&#0160;(e.g.&#0160;one&#0160;that&#0160;overrides&#0160;the</span><br />
+<a class="lnum" href="#145" name="145">0145</a><span class="string">&#0160;&#0160;&#0160;&#0160;``.default()``&#0160;method&#0160;to&#0160;serialize&#0160;additional&#0160;types),&#0160;specify&#0160;it&#0160;with</span><br />
+<a class="lnum" href="#146" name="146">0146</a><span class="string">&#0160;&#0160;&#0160;&#0160;the&#0160;``cls``&#0160;kwarg.</span><br />
+<a class="lnum" href="#147" name="147">0147</a><span class="string">&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#148" name="148">0148</a>&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;cached&#0160;encoder</span><br />
+<a class="lnum" href="#149" name="149">0149</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="op">(</span><span class="name">skipkeys</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">False</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">ensure_ascii</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">True</span>&#0160;<span class="keyword">and</span><br />
+<a class="lnum" href="#150" name="150">0150</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">check_circular</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">True</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">allow_nan</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">True</span>&#0160;<span class="keyword">and</span><br />
+<a class="lnum" href="#151" name="151">0151</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">cls</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">indent</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">separators</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span>&#0160;<span class="keyword">and</span><br />
+<a class="lnum" href="#152" name="152">0152</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">encoding</span>&#0160;<span class="op">==</span>&#0160;<span class="string">'utf-8'</span>&#0160;<span class="keyword">and</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">kw</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#153" name="153">0153</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">iterable</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_default_encoder</span><span class="op">.</span><span class="name">iterencode</span><span class="op">(</span><span class="name">obj</span><span class="op">)</span><br />
+<a class="lnum" href="#154" name="154">0154</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#155" name="155">0155</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">cls</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#156" name="156">0156</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">cls</span>&#0160;<span class="op">=</span>&#0160;<span class="name">JSONEncoder</span><br />
+<a class="lnum" href="#157" name="157">0157</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">iterable</span>&#0160;<span class="op">=</span>&#0160;<span class="name">cls</span><span class="op">(</span><span class="name">skipkeys</span><span class="op">=</span><span class="name">skipkeys</span><span class="op">,</span>&#0160;<span class="name">ensure_ascii</span><span class="op">=</span><span class="name">ensure_ascii</span><span class="op">,</span><br />
+<a class="lnum" href="#158" name="158">0158</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">check_circular</span><span class="op">=</span><span class="name">check_circular</span><span class="op">,</span>&#0160;<span class="name">allow_nan</span><span class="op">=</span><span class="name">allow_nan</span><span class="op">,</span>&#0160;<span class="name">indent</span><span class="op">=</span><span class="name">indent</span><span class="op">,</span><br />
+<a class="lnum" href="#159" name="159">0159</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">separators</span><span class="op">=</span><span class="name">separators</span><span class="op">,</span>&#0160;<span class="name">encoding</span><span class="op">=</span><span class="name">encoding</span><span class="op">,</span>&#0160;<span class="op">**</span><span class="name">kw</span><span class="op">)</span><span class="op">.</span><span class="name">iterencode</span><span class="op">(</span><span class="name">obj</span><span class="op">)</span><br />
+<a class="lnum" href="#160" name="160">0160</a>&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;could&#0160;accelerate&#0160;with&#0160;writelines&#0160;in&#0160;some&#0160;versions&#0160;of&#0160;Python,&#0160;at</span><br />
+<a class="lnum" href="#161" name="161">0161</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;a&#0160;debuggability&#0160;cost</span><br />
+<a class="lnum" href="#162" name="162">0162</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;<span class="keyword">for</span>&#0160;<span class="name">chunk</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">iterable</span><span class="op">:</span><br />
+<a class="lnum" href="#163" name="163">0163</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">fp</span><span class="op">.</span><span class="name">write</span><span class="op">(</span><span class="name">chunk</span><span class="op">)</span><br />
+<a class="lnum" href="#164" name="164">0164</a><br />
+<a class="lnum" href="#165" name="165">0165</a><br />
+<a class="lnum" href="#166" name="166">0166</a><span class="keyword">def</span>&#0160;<span class="name">dumps</span><span class="op">(</span><span class="name">obj</span><span class="op">,</span>&#0160;<span class="name">skipkeys</span><span class="op">=</span><span class="name">False</span><span class="op">,</span>&#0160;<span class="name">ensure_ascii</span><span class="op">=</span><span class="name">True</span><span class="op">,</span>&#0160;<span class="name">check_circular</span><span class="op">=</span><span class="name">True</span><span class="op">,</span><br />
+<a class="lnum" href="#167" name="167">0167</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">allow_nan</span><span class="op">=</span><span class="name">True</span><span class="op">,</span>&#0160;<span class="name">cls</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="name">indent</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="name">separators</span><span class="op">=</span><span class="name">None</span><span class="op">,</span><br />
+<a class="lnum" href="#168" name="168">0168</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">encoding</span><span class="op">=</span><span class="string">'utf-8'</span><span class="op">,</span>&#0160;<span class="op">**</span><span class="name">kw</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#169" name="169">0169</a>&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#170" name="170">0170</a><span class="string">&#0160;&#0160;&#0160;&#0160;Serialize&#0160;``obj``&#0160;to&#0160;a&#0160;JSON&#0160;formatted&#0160;``str``.</span><br />
+<a class="lnum" href="#171" name="171">0171</a><span class="string"></span><br />
+<a class="lnum" href="#172" name="172">0172</a><span class="string">&#0160;&#0160;&#0160;&#0160;If&#0160;``skipkeys``&#0160;is&#0160;``True``&#0160;then&#0160;``dict``&#0160;keys&#0160;that&#0160;are&#0160;not&#0160;basic&#0160;types</span><br />
+<a class="lnum" href="#173" name="173">0173</a><span class="string">&#0160;&#0160;&#0160;&#0160;(``str``,&#0160;``unicode``,&#0160;``int``,&#0160;``long``,&#0160;``float``,&#0160;``bool``,&#0160;``None``)&#0160;</span><br />
+<a class="lnum" href="#174" name="174">0174</a><span class="string">&#0160;&#0160;&#0160;&#0160;will&#0160;be&#0160;skipped&#0160;instead&#0160;of&#0160;raising&#0160;a&#0160;``TypeError``.</span><br />
+<a class="lnum" href="#175" name="175">0175</a><span class="string"></span><br />
+<a class="lnum" href="#176" name="176">0176</a><span class="string">&#0160;&#0160;&#0160;&#0160;If&#0160;``ensure_ascii``&#0160;is&#0160;``False``,&#0160;then&#0160;the&#0160;return&#0160;value&#0160;will&#0160;be&#0160;a</span><br />
+<a class="lnum" href="#177" name="177">0177</a><span class="string">&#0160;&#0160;&#0160;&#0160;``unicode``&#0160;instance&#0160;subject&#0160;to&#0160;normal&#0160;Python&#0160;``str``&#0160;to&#0160;``unicode``</span><br />
+<a class="lnum" href="#178" name="178">0178</a><span class="string">&#0160;&#0160;&#0160;&#0160;coercion&#0160;rules&#0160;instead&#0160;of&#0160;being&#0160;escaped&#0160;to&#0160;an&#0160;ASCII&#0160;``str``.</span><br />
+<a class="lnum" href="#179" name="179">0179</a><span class="string"></span><br />
+<a class="lnum" href="#180" name="180">0180</a><span class="string">&#0160;&#0160;&#0160;&#0160;If&#0160;``check_circular``&#0160;is&#0160;``False``,&#0160;then&#0160;the&#0160;circular&#0160;reference&#0160;check</span><br />
+<a class="lnum" href="#181" name="181">0181</a><span class="string">&#0160;&#0160;&#0160;&#0160;for&#0160;container&#0160;types&#0160;will&#0160;be&#0160;skipped&#0160;and&#0160;a&#0160;circular&#0160;reference&#0160;will</span><br />
+<a class="lnum" href="#182" name="182">0182</a><span class="string">&#0160;&#0160;&#0160;&#0160;result&#0160;in&#0160;an&#0160;``OverflowError``&#0160;(or&#0160;worse).</span><br />
+<a class="lnum" href="#183" name="183">0183</a><span class="string"></span><br />
+<a class="lnum" href="#184" name="184">0184</a><span class="string">&#0160;&#0160;&#0160;&#0160;If&#0160;``allow_nan``&#0160;is&#0160;``False``,&#0160;then&#0160;it&#0160;will&#0160;be&#0160;a&#0160;``ValueError``&#0160;to</span><br />
+<a class="lnum" href="#185" name="185">0185</a><span class="string">&#0160;&#0160;&#0160;&#0160;serialize&#0160;out&#0160;of&#0160;range&#0160;``float``&#0160;values&#0160;(``nan``,&#0160;``inf``,&#0160;``-inf``)&#0160;in</span><br />
+<a class="lnum" href="#186" name="186">0186</a><span class="string">&#0160;&#0160;&#0160;&#0160;strict&#0160;compliance&#0160;of&#0160;the&#0160;JSON&#0160;specification,&#0160;instead&#0160;of&#0160;using&#0160;the</span><br />
+<a class="lnum" href="#187" name="187">0187</a><span class="string">&#0160;&#0160;&#0160;&#0160;JavaScript&#0160;equivalents&#0160;(``NaN``,&#0160;``Infinity``,&#0160;``-Infinity``).</span><br />
+<a class="lnum" href="#188" name="188">0188</a><span class="string"></span><br />
+<a class="lnum" href="#189" name="189">0189</a><span class="string">&#0160;&#0160;&#0160;&#0160;If&#0160;``indent``&#0160;is&#0160;a&#0160;non-negative&#0160;integer,&#0160;then&#0160;JSON&#0160;array&#0160;elements&#0160;and</span><br />
+<a class="lnum" href="#190" name="190">0190</a><span class="string">&#0160;&#0160;&#0160;&#0160;object&#0160;members&#0160;will&#0160;be&#0160;pretty-printed&#0160;with&#0160;that&#0160;indent&#0160;level.&#0160;An&#0160;indent</span><br />
+<a class="lnum" href="#191" name="191">0191</a><span class="string">&#0160;&#0160;&#0160;&#0160;level&#0160;of&#0160;0&#0160;will&#0160;only&#0160;insert&#0160;newlines.&#0160;``None``&#0160;is&#0160;the&#0160;most&#0160;compact</span><br />
+<a class="lnum" href="#192" name="192">0192</a><span class="string">&#0160;&#0160;&#0160;&#0160;representation.</span><br />
+<a class="lnum" href="#193" name="193">0193</a><span class="string"></span><br />
+<a class="lnum" href="#194" name="194">0194</a><span class="string">&#0160;&#0160;&#0160;&#0160;If&#0160;``separators``&#0160;is&#0160;an&#0160;``(item_separator,&#0160;dict_separator)``&#0160;tuple</span><br />
+<a class="lnum" href="#195" name="195">0195</a><span class="string">&#0160;&#0160;&#0160;&#0160;then&#0160;it&#0160;will&#0160;be&#0160;used&#0160;instead&#0160;of&#0160;the&#0160;default&#0160;``(',&#0160;',&#0160;':&#0160;')``&#0160;separators.</span><br />
+<a class="lnum" href="#196" name="196">0196</a><span class="string">&#0160;&#0160;&#0160;&#0160;``(',',&#0160;':')``&#0160;is&#0160;the&#0160;most&#0160;compact&#0160;JSON&#0160;representation.</span><br />
+<a class="lnum" href="#197" name="197">0197</a><span class="string"></span><br />
+<a class="lnum" href="#198" name="198">0198</a><span class="string">&#0160;&#0160;&#0160;&#0160;``encoding``&#0160;is&#0160;the&#0160;character&#0160;encoding&#0160;for&#0160;str&#0160;instances,&#0160;default&#0160;is&#0160;UTF-8.</span><br />
+<a class="lnum" href="#199" name="199">0199</a><span class="string"></span><br />
+<a class="lnum" href="#200" name="200">0200</a><span class="string">&#0160;&#0160;&#0160;&#0160;To&#0160;use&#0160;a&#0160;custom&#0160;``JSONEncoder``&#0160;subclass&#0160;(e.g.&#0160;one&#0160;that&#0160;overrides&#0160;the</span><br />
+<a class="lnum" href="#201" name="201">0201</a><span class="string">&#0160;&#0160;&#0160;&#0160;``.default()``&#0160;method&#0160;to&#0160;serialize&#0160;additional&#0160;types),&#0160;specify&#0160;it&#0160;with</span><br />
+<a class="lnum" href="#202" name="202">0202</a><span class="string">&#0160;&#0160;&#0160;&#0160;the&#0160;``cls``&#0160;kwarg.</span><br />
+<a class="lnum" href="#203" name="203">0203</a><span class="string">&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#204" name="204">0204</a>&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;cached&#0160;encoder</span><br />
+<a class="lnum" href="#205" name="205">0205</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="op">(</span><span class="name">skipkeys</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">False</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">ensure_ascii</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">True</span>&#0160;<span class="keyword">and</span><br />
+<a class="lnum" href="#206" name="206">0206</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">check_circular</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">True</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">allow_nan</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">True</span>&#0160;<span class="keyword">and</span><br />
+<a class="lnum" href="#207" name="207">0207</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">cls</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">indent</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">separators</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span>&#0160;<span class="keyword">and</span><br />
+<a class="lnum" href="#208" name="208">0208</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">encoding</span>&#0160;<span class="op">==</span>&#0160;<span class="string">'utf-8'</span>&#0160;<span class="keyword">and</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">kw</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#209" name="209">0209</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">_default_encoder</span><span class="op">.</span><span class="name">encode</span><span class="op">(</span><span class="name">obj</span><span class="op">)</span><br />
+<a class="lnum" href="#210" name="210">0210</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">cls</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#211" name="211">0211</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">cls</span>&#0160;<span class="op">=</span>&#0160;<span class="name">JSONEncoder</span><br />
+<a class="lnum" href="#212" name="212">0212</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">cls</span><span class="op">(</span><br />
+<a class="lnum" href="#213" name="213">0213</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">skipkeys</span><span class="op">=</span><span class="name">skipkeys</span><span class="op">,</span>&#0160;<span class="name">ensure_ascii</span><span class="op">=</span><span class="name">ensure_ascii</span><span class="op">,</span><br />
+<a class="lnum" href="#214" name="214">0214</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">check_circular</span><span class="op">=</span><span class="name">check_circular</span><span class="op">,</span>&#0160;<span class="name">allow_nan</span><span class="op">=</span><span class="name">allow_nan</span><span class="op">,</span>&#0160;<span class="name">indent</span><span class="op">=</span><span class="name">indent</span><span class="op">,</span><br />
+<a class="lnum" href="#215" name="215">0215</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">separators</span><span class="op">=</span><span class="name">separators</span><span class="op">,</span>&#0160;<span class="name">encoding</span><span class="op">=</span><span class="name">encoding</span><span class="op">,</span><br />
+<a class="lnum" href="#216" name="216">0216</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="op">**</span><span class="name">kw</span><span class="op">)</span><span class="op">.</span><span class="name">encode</span><span class="op">(</span><span class="name">obj</span><span class="op">)</span><br />
+<a class="lnum" href="#217" name="217">0217</a><br />
+<a class="lnum" href="#218" name="218">0218</a><span class="name">_default_decoder</span>&#0160;<span class="op">=</span>&#0160;<span class="name">JSONDecoder</span><span class="op">(</span><span class="name">encoding</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="name">object_hook</span><span class="op">=</span><span class="name">None</span><span class="op">)</span><br />
+<a class="lnum" href="#219" name="219">0219</a><br />
+<a class="lnum" href="#220" name="220">0220</a><span class="keyword">def</span>&#0160;<span class="name">load</span><span class="op">(</span><span class="name">fp</span><span class="op">,</span>&#0160;<span class="name">encoding</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="name">cls</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="name">object_hook</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="op">**</span><span class="name">kw</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#221" name="221">0221</a>&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#222" name="222">0222</a><span class="string">&#0160;&#0160;&#0160;&#0160;Deserialize&#0160;``fp``&#0160;(a&#0160;``.read()``-supporting&#0160;file-like&#0160;object&#0160;containing</span><br />
+<a class="lnum" href="#223" name="223">0223</a><span class="string">&#0160;&#0160;&#0160;&#0160;a&#0160;JSON&#0160;document)&#0160;to&#0160;a&#0160;Python&#0160;object.</span><br />
+<a class="lnum" href="#224" name="224">0224</a><span class="string"></span><br />
+<a class="lnum" href="#225" name="225">0225</a><span class="string">&#0160;&#0160;&#0160;&#0160;If&#0160;the&#0160;contents&#0160;of&#0160;``fp``&#0160;is&#0160;encoded&#0160;with&#0160;an&#0160;ASCII&#0160;based&#0160;encoding&#0160;other</span><br />
+<a class="lnum" href="#226" name="226">0226</a><span class="string">&#0160;&#0160;&#0160;&#0160;than&#0160;utf-8&#0160;(e.g.&#0160;latin-1),&#0160;then&#0160;an&#0160;appropriate&#0160;``encoding``&#0160;name&#0160;must</span><br />
+<a class="lnum" href="#227" name="227">0227</a><span class="string">&#0160;&#0160;&#0160;&#0160;be&#0160;specified.&#0160;Encodings&#0160;that&#0160;are&#0160;not&#0160;ASCII&#0160;based&#0160;(such&#0160;as&#0160;UCS-2)&#0160;are</span><br />
+<a class="lnum" href="#228" name="228">0228</a><span class="string">&#0160;&#0160;&#0160;&#0160;not&#0160;allowed,&#0160;and&#0160;should&#0160;be&#0160;wrapped&#0160;with</span><br />
+<a class="lnum" href="#229" name="229">0229</a><span class="string">&#0160;&#0160;&#0160;&#0160;``codecs.getreader(fp)(encoding)``,&#0160;or&#0160;simply&#0160;decoded&#0160;to&#0160;a&#0160;``unicode``</span><br />
+<a class="lnum" href="#230" name="230">0230</a><span class="string">&#0160;&#0160;&#0160;&#0160;object&#0160;and&#0160;passed&#0160;to&#0160;``loads()``</span><br />
+<a class="lnum" href="#231" name="231">0231</a><span class="string"></span><br />
+<a class="lnum" href="#232" name="232">0232</a><span class="string">&#0160;&#0160;&#0160;&#0160;``object_hook``&#0160;is&#0160;an&#0160;optional&#0160;function&#0160;that&#0160;will&#0160;be&#0160;called&#0160;with&#0160;the</span><br />
+<a class="lnum" href="#233" name="233">0233</a><span class="string">&#0160;&#0160;&#0160;&#0160;result&#0160;of&#0160;any&#0160;object&#0160;literal&#0160;decode&#0160;(a&#0160;``dict``).&#0160;The&#0160;return&#0160;value&#0160;of</span><br />
+<a class="lnum" href="#234" name="234">0234</a><span class="string">&#0160;&#0160;&#0160;&#0160;``object_hook``&#0160;will&#0160;be&#0160;used&#0160;instead&#0160;of&#0160;the&#0160;``dict``.&#0160;This&#0160;feature</span><br />
+<a class="lnum" href="#235" name="235">0235</a><span class="string">&#0160;&#0160;&#0160;&#0160;can&#0160;be&#0160;used&#0160;to&#0160;implement&#0160;custom&#0160;decoders&#0160;(e.g.&#0160;JSON-RPC&#0160;class&#0160;hinting).</span><br />
+<a class="lnum" href="#236" name="236">0236</a><span class="string">&#0160;&#0160;&#0160;&#0160;</span><br />
+<a class="lnum" href="#237" name="237">0237</a><span class="string">&#0160;&#0160;&#0160;&#0160;To&#0160;use&#0160;a&#0160;custom&#0160;``JSONDecoder``&#0160;subclass,&#0160;specify&#0160;it&#0160;with&#0160;the&#0160;``cls``</span><br />
+<a class="lnum" href="#238" name="238">0238</a><span class="string">&#0160;&#0160;&#0160;&#0160;kwarg.</span><br />
+<a class="lnum" href="#239" name="239">0239</a><span class="string">&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#240" name="240">0240</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">loads</span><span class="op">(</span><span class="name">fp</span><span class="op">.</span><span class="name">read</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><br />
+<a class="lnum" href="#241" name="241">0241</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">encoding</span><span class="op">=</span><span class="name">encoding</span><span class="op">,</span>&#0160;<span class="name">cls</span><span class="op">=</span><span class="name">cls</span><span class="op">,</span>&#0160;<span class="name">object_hook</span><span class="op">=</span><span class="name">object_hook</span><span class="op">,</span>&#0160;<span class="op">**</span><span class="name">kw</span><span class="op">)</span><br />
+<a class="lnum" href="#242" name="242">0242</a><br />
+<a class="lnum" href="#243" name="243">0243</a><span class="keyword">def</span>&#0160;<span class="name">loads</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">encoding</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="name">cls</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="name">object_hook</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="op">**</span><span class="name">kw</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#244" name="244">0244</a>&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#245" name="245">0245</a><span class="string">&#0160;&#0160;&#0160;&#0160;Deserialize&#0160;``s``&#0160;(a&#0160;``str``&#0160;or&#0160;``unicode``&#0160;instance&#0160;containing&#0160;a&#0160;JSON</span><br />
+<a class="lnum" href="#246" name="246">0246</a><span class="string">&#0160;&#0160;&#0160;&#0160;document)&#0160;to&#0160;a&#0160;Python&#0160;object.</span><br />
+<a class="lnum" href="#247" name="247">0247</a><span class="string"></span><br />
+<a class="lnum" href="#248" name="248">0248</a><span class="string">&#0160;&#0160;&#0160;&#0160;If&#0160;``s``&#0160;is&#0160;a&#0160;``str``&#0160;instance&#0160;and&#0160;is&#0160;encoded&#0160;with&#0160;an&#0160;ASCII&#0160;based&#0160;encoding</span><br />
+<a class="lnum" href="#249" name="249">0249</a><span class="string">&#0160;&#0160;&#0160;&#0160;other&#0160;than&#0160;utf-8&#0160;(e.g.&#0160;latin-1)&#0160;then&#0160;an&#0160;appropriate&#0160;``encoding``&#0160;name</span><br />
+<a class="lnum" href="#250" name="250">0250</a><span class="string">&#0160;&#0160;&#0160;&#0160;must&#0160;be&#0160;specified.&#0160;Encodings&#0160;that&#0160;are&#0160;not&#0160;ASCII&#0160;based&#0160;(such&#0160;as&#0160;UCS-2)</span><br />
+<a class="lnum" href="#251" name="251">0251</a><span class="string">&#0160;&#0160;&#0160;&#0160;are&#0160;not&#0160;allowed&#0160;and&#0160;should&#0160;be&#0160;decoded&#0160;to&#0160;``unicode``&#0160;first.</span><br />
+<a class="lnum" href="#252" name="252">0252</a><span class="string"></span><br />
+<a class="lnum" href="#253" name="253">0253</a><span class="string">&#0160;&#0160;&#0160;&#0160;``object_hook``&#0160;is&#0160;an&#0160;optional&#0160;function&#0160;that&#0160;will&#0160;be&#0160;called&#0160;with&#0160;the</span><br />
+<a class="lnum" href="#254" name="254">0254</a><span class="string">&#0160;&#0160;&#0160;&#0160;result&#0160;of&#0160;any&#0160;object&#0160;literal&#0160;decode&#0160;(a&#0160;``dict``).&#0160;The&#0160;return&#0160;value&#0160;of</span><br />
+<a class="lnum" href="#255" name="255">0255</a><span class="string">&#0160;&#0160;&#0160;&#0160;``object_hook``&#0160;will&#0160;be&#0160;used&#0160;instead&#0160;of&#0160;the&#0160;``dict``.&#0160;This&#0160;feature</span><br />
+<a class="lnum" href="#256" name="256">0256</a><span class="string">&#0160;&#0160;&#0160;&#0160;can&#0160;be&#0160;used&#0160;to&#0160;implement&#0160;custom&#0160;decoders&#0160;(e.g.&#0160;JSON-RPC&#0160;class&#0160;hinting).</span><br />
+<a class="lnum" href="#257" name="257">0257</a><span class="string"></span><br />
+<a class="lnum" href="#258" name="258">0258</a><span class="string">&#0160;&#0160;&#0160;&#0160;To&#0160;use&#0160;a&#0160;custom&#0160;``JSONDecoder``&#0160;subclass,&#0160;specify&#0160;it&#0160;with&#0160;the&#0160;``cls``</span><br />
+<a class="lnum" href="#259" name="259">0259</a><span class="string">&#0160;&#0160;&#0160;&#0160;kwarg.</span><br />
+<a class="lnum" href="#260" name="260">0260</a><span class="string">&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#261" name="261">0261</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">cls</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">encoding</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">object_hook</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span>&#0160;<span class="keyword">and</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">kw</span><span class="op">:</span><br />
+<a class="lnum" href="#262" name="262">0262</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">_default_decoder</span><span class="op">.</span><span class="name">decode</span><span class="op">(</span><span class="name">s</span><span class="op">)</span><br />
+<a class="lnum" href="#263" name="263">0263</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">cls</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#264" name="264">0264</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">cls</span>&#0160;<span class="op">=</span>&#0160;<span class="name">JSONDecoder</span><br />
+<a class="lnum" href="#265" name="265">0265</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">object_hook</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#266" name="266">0266</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">kw</span><span class="op">[</span><span class="string">'object_hook'</span><span class="op">]</span>&#0160;<span class="op">=</span>&#0160;<span class="name">object_hook</span><br />
+<a class="lnum" href="#267" name="267">0267</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">cls</span><span class="op">(</span><span class="name">encoding</span><span class="op">=</span><span class="name">encoding</span><span class="op">,</span>&#0160;<span class="op">**</span><span class="name">kw</span><span class="op">)</span><span class="op">.</span><span class="name">decode</span><span class="op">(</span><span class="name">s</span><span class="op">)</span><br />
+<a class="lnum" href="#268" name="268">0268</a><br />
+<a class="lnum" href="#269" name="269">0269</a><span class="keyword">def</span>&#0160;<span class="name">read</span><span class="op">(</span><span class="name">s</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#270" name="270">0270</a>&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#271" name="271">0271</a><span class="string">&#0160;&#0160;&#0160;&#0160;json-py&#0160;API&#0160;compatibility&#0160;hook.&#0160;Use&#0160;loads(s)&#0160;instead.</span><br />
+<a class="lnum" href="#272" name="272">0272</a><span class="string">&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#273" name="273">0273</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">import</span>&#0160;<span class="name">warnings</span><br />
+<a class="lnum" href="#274" name="274">0274</a>&#0160;&#0160;&#0160;&#0160;<span class="name">warnings</span><span class="op">.</span><span class="name">warn</span><span class="op">(</span><span class="string">"simplejson.loads(s)&#0160;should&#0160;be&#0160;used&#0160;instead&#0160;of&#0160;read(s)"</span><span class="op">,</span><br />
+<a class="lnum" href="#275" name="275">0275</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">DeprecationWarning</span><span class="op">)</span><br />
+<a class="lnum" href="#276" name="276">0276</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">loads</span><span class="op">(</span><span class="name">s</span><span class="op">)</span><br />
+<a class="lnum" href="#277" name="277">0277</a><br />
+<a class="lnum" href="#278" name="278">0278</a><span class="keyword">def</span>&#0160;<span class="name">write</span><span class="op">(</span><span class="name">obj</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#279" name="279">0279</a>&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#280" name="280">0280</a><span class="string">&#0160;&#0160;&#0160;&#0160;json-py&#0160;API&#0160;compatibility&#0160;hook.&#0160;Use&#0160;dumps(s)&#0160;instead.</span><br />
+<a class="lnum" href="#281" name="281">0281</a><span class="string">&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#282" name="282">0282</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">import</span>&#0160;<span class="name">warnings</span><br />
+<a class="lnum" href="#283" name="283">0283</a>&#0160;&#0160;&#0160;&#0160;<span class="name">warnings</span><span class="op">.</span><span class="name">warn</span><span class="op">(</span><span class="string">"simplejson.dumps(s)&#0160;should&#0160;be&#0160;used&#0160;instead&#0160;of&#0160;write(s)"</span><span class="op">,</span><br />
+<a class="lnum" href="#284" name="284">0284</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">DeprecationWarning</span><span class="op">)</span><br />
+<a class="lnum" href="#285" name="285">0285</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">dumps</span><span class="op">(</span><span class="name">obj</span><span class="op">)</span></code></div></body></html>
\ No newline at end of file
diff --git a/src/simplejson/docs/simplejson/decoder.py.html b/src/simplejson/docs/simplejson/decoder.py.html
new file mode 100644 (file)
index 0000000..d252e69
--- /dev/null
@@ -0,0 +1,345 @@
+<html><head><title>/Users/bob/src/simplejson/simplejson/decoder.py</title>
+        <script type="text/javascript"><!--
+        
+function show_line_range() {
+    var href = document.location.href;
+    if (href.indexOf('?') == -1) {
+        return;
+    }
+    var qs = href.substring(href.indexOf('?')+1);
+    if (qs.indexOf('#') >= 0) {
+        qs = qs.substring(0, qs.indexOf('#'));
+    }
+    var first = qs.match(/f=(\d+)/)[1];
+    var last = qs.match(/l=(\d+)/)[1];
+    if (! first || ! last) {
+        return;
+    }
+    var anchors = document.getElementsByTagName('A');
+    var container = document.createElement('DIV');
+    container.className = 'highlighted';
+    var children = [];
+    var start = null;
+    var parent = null;
+    var highlight = false;
+    for (var i = 0; i < anchors.length; i++) {
+        var el = anchors[i];
+        if (el.getAttribute('name') == first) {
+            start = el.previousSibling;
+            parent = el.parentNode;
+            highlight = true;
+        }
+        if (el.getAttribute('name') == last) {
+            break;
+        }
+        if (highlight) {
+            children[children.length] = el;
+            el = el.nextSibling;
+            while (el && el.tagName != 'A') {
+                children[children.length] = el;
+                el = el.nextSibling;
+            }
+        }
+    }
+    for (i=0; i<children.length; i++) {
+        container.appendChild(children[i]);
+    }
+    if (start) {
+        start.parentNode.insertBefore(container, start.nextSibling);
+    } else {
+        parent.insertBefore(container, parent.childNodes[0]);
+    }
+}
+
+        // --></script>
+        <style>
+        div.python {
+          color: #333
+        }
+        div.python a.lnum {
+          color: #555;
+          background-color: #eee;
+          border-right: 1px solid #999;
+          padding-right: 2px;
+          margin-right: 4px;
+        }
+        div.python span.comment { color: #933 }
+        div.python span.keyword { color: #a3e; font-weight: bold  }
+        div.python span.op { color: #c96 }
+        div.python span.string { color: #6a6 }
+        div.python span.name { }
+        div.python span.text { color: #333 }
+        div.highlighted { background-color: #ff9; border: 1px solid #009 }
+        </style></head><body onload="show_line_range()"><div class="python"><code><a class="lnum" href="#1" name="1">0001</a><span class="string">"""</span><br />
+<a class="lnum" href="#2" name="2">0002</a><span class="string">Implementation&#0160;of&#0160;JSONDecoder</span><br />
+<a class="lnum" href="#3" name="3">0003</a><span class="string">"""</span><br />
+<a class="lnum" href="#4" name="4">0004</a><span class="keyword">import</span>&#0160;<span class="name">re</span><br />
+<a class="lnum" href="#5" name="5">0005</a><br />
+<a class="lnum" href="#6" name="6">0006</a><span class="keyword">from</span>&#0160;<span class="name">simplejson</span><span class="op">.</span><span class="name">scanner</span>&#0160;<span class="keyword">import</span>&#0160;<span class="name">Scanner</span><span class="op">,</span>&#0160;<span class="name">pattern</span><br />
+<a class="lnum" href="#7" name="7">0007</a><br />
+<a class="lnum" href="#8" name="8">0008</a><span class="name">FLAGS</span>&#0160;<span class="op">=</span>&#0160;<span class="name">re</span><span class="op">.</span><span class="name">VERBOSE</span>&#0160;<span class="op">|</span>&#0160;<span class="name">re</span><span class="op">.</span><span class="name">MULTILINE</span>&#0160;<span class="op">|</span>&#0160;<span class="name">re</span><span class="op">.</span><span class="name">DOTALL</span><br />
+<a class="lnum" href="#9" name="9">0009</a><br />
+<a class="lnum" href="#10" name="10">0010</a><span class="keyword">def</span>&#0160;<span class="name">_floatconstants</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#11" name="11">0011</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">import</span>&#0160;<span class="name">struct</span><br />
+<a class="lnum" href="#12" name="12">0012</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">import</span>&#0160;<span class="name">sys</span><br />
+<a class="lnum" href="#13" name="13">0013</a>&#0160;&#0160;&#0160;&#0160;<span class="name">_BYTES</span>&#0160;<span class="op">=</span>&#0160;<span class="string">'7FF80000000000007FF0000000000000'</span><span class="op">.</span><span class="name">decode</span><span class="op">(</span><span class="string">'hex'</span><span class="op">)</span><br />
+<a class="lnum" href="#14" name="14">0014</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">sys</span><span class="op">.</span><span class="name">byteorder</span>&#0160;<span class="op">!=</span>&#0160;<span class="string">'big'</span><span class="op">:</span><br />
+<a class="lnum" href="#15" name="15">0015</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">_BYTES</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_BYTES</span><span class="op">[</span><span class="op">:</span><span class="number">8</span><span class="op">]</span><span class="op">[</span><span class="op">:</span><span class="op">:</span><span class="op">-</span><span class="number">1</span><span class="op">]</span>&#0160;<span class="op">+</span>&#0160;<span class="name">_BYTES</span><span class="op">[</span><span class="number">8</span><span class="op">:</span><span class="op">]</span><span class="op">[</span><span class="op">:</span><span class="op">:</span><span class="op">-</span><span class="number">1</span><span class="op">]</span><br />
+<a class="lnum" href="#16" name="16">0016</a>&#0160;&#0160;&#0160;&#0160;<span class="name">nan</span><span class="op">,</span>&#0160;<span class="name">inf</span>&#0160;<span class="op">=</span>&#0160;<span class="name">struct</span><span class="op">.</span><span class="name">unpack</span><span class="op">(</span><span class="string">'dd'</span><span class="op">,</span>&#0160;<span class="name">_BYTES</span><span class="op">)</span><br />
+<a class="lnum" href="#17" name="17">0017</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">nan</span><span class="op">,</span>&#0160;<span class="name">inf</span><span class="op">,</span>&#0160;<span class="op">-</span><span class="name">inf</span><br />
+<a class="lnum" href="#18" name="18">0018</a><br />
+<a class="lnum" href="#19" name="19">0019</a><span class="name">NaN</span><span class="op">,</span>&#0160;<span class="name">PosInf</span><span class="op">,</span>&#0160;<span class="name">NegInf</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_floatconstants</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#20" name="20">0020</a><br />
+<a class="lnum" href="#21" name="21">0021</a><span class="keyword">def</span>&#0160;<span class="name">linecol</span><span class="op">(</span><span class="name">doc</span><span class="op">,</span>&#0160;<span class="name">pos</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#22" name="22">0022</a>&#0160;&#0160;&#0160;&#0160;<span class="name">lineno</span>&#0160;<span class="op">=</span>&#0160;<span class="name">doc</span><span class="op">.</span><span class="name">count</span><span class="op">(</span><span class="string">'\n'</span><span class="op">,</span>&#0160;<span class="number">0</span><span class="op">,</span>&#0160;<span class="name">pos</span><span class="op">)</span>&#0160;<span class="op">+</span>&#0160;<span class="number">1</span><br />
+<a class="lnum" href="#23" name="23">0023</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">lineno</span>&#0160;<span class="op">==</span>&#0160;<span class="number">1</span><span class="op">:</span><br />
+<a class="lnum" href="#24" name="24">0024</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">colno</span>&#0160;<span class="op">=</span>&#0160;<span class="name">pos</span><br />
+<a class="lnum" href="#25" name="25">0025</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#26" name="26">0026</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">colno</span>&#0160;<span class="op">=</span>&#0160;<span class="name">pos</span>&#0160;<span class="op">-</span>&#0160;<span class="name">doc</span><span class="op">.</span><span class="name">rindex</span><span class="op">(</span><span class="string">'\n'</span><span class="op">,</span>&#0160;<span class="number">0</span><span class="op">,</span>&#0160;<span class="name">pos</span><span class="op">)</span><br />
+<a class="lnum" href="#27" name="27">0027</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">lineno</span><span class="op">,</span>&#0160;<span class="name">colno</span><br />
+<a class="lnum" href="#28" name="28">0028</a><br />
+<a class="lnum" href="#29" name="29">0029</a><span class="keyword">def</span>&#0160;<span class="name">errmsg</span><span class="op">(</span><span class="name">msg</span><span class="op">,</span>&#0160;<span class="name">doc</span><span class="op">,</span>&#0160;<span class="name">pos</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">=</span><span class="name">None</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#30" name="30">0030</a>&#0160;&#0160;&#0160;&#0160;<span class="name">lineno</span><span class="op">,</span>&#0160;<span class="name">colno</span>&#0160;<span class="op">=</span>&#0160;<span class="name">linecol</span><span class="op">(</span><span class="name">doc</span><span class="op">,</span>&#0160;<span class="name">pos</span><span class="op">)</span><br />
+<a class="lnum" href="#31" name="31">0031</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">end</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#32" name="32">0032</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="string">'%s:&#0160;line&#0160;%d&#0160;column&#0160;%d&#0160;(char&#0160;%d)'</span>&#0160;<span class="op">%</span>&#0160;<span class="op">(</span><span class="name">msg</span><span class="op">,</span>&#0160;<span class="name">lineno</span><span class="op">,</span>&#0160;<span class="name">colno</span><span class="op">,</span>&#0160;<span class="name">pos</span><span class="op">)</span><br />
+<a class="lnum" href="#33" name="33">0033</a>&#0160;&#0160;&#0160;&#0160;<span class="name">endlineno</span><span class="op">,</span>&#0160;<span class="name">endcolno</span>&#0160;<span class="op">=</span>&#0160;<span class="name">linecol</span><span class="op">(</span><span class="name">doc</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><br />
+<a class="lnum" href="#34" name="34">0034</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="string">'%s:&#0160;line&#0160;%d&#0160;column&#0160;%d&#0160;-&#0160;line&#0160;%d&#0160;column&#0160;%d&#0160;(char&#0160;%d&#0160;-&#0160;%d)'</span>&#0160;<span class="op">%</span>&#0160;<span class="op">(</span><br />
+<a class="lnum" href="#35" name="35">0035</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">msg</span><span class="op">,</span>&#0160;<span class="name">lineno</span><span class="op">,</span>&#0160;<span class="name">colno</span><span class="op">,</span>&#0160;<span class="name">endlineno</span><span class="op">,</span>&#0160;<span class="name">endcolno</span><span class="op">,</span>&#0160;<span class="name">pos</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><br />
+<a class="lnum" href="#36" name="36">0036</a><br />
+<a class="lnum" href="#37" name="37">0037</a><span class="name">_CONSTANTS</span>&#0160;<span class="op">=</span>&#0160;<span class="op">{</span><br />
+<a class="lnum" href="#38" name="38">0038</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'-Infinity'</span><span class="op">:</span>&#0160;<span class="name">NegInf</span><span class="op">,</span><br />
+<a class="lnum" href="#39" name="39">0039</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'Infinity'</span><span class="op">:</span>&#0160;<span class="name">PosInf</span><span class="op">,</span><br />
+<a class="lnum" href="#40" name="40">0040</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'NaN'</span><span class="op">:</span>&#0160;<span class="name">NaN</span><span class="op">,</span><br />
+<a class="lnum" href="#41" name="41">0041</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'true'</span><span class="op">:</span>&#0160;<span class="name">True</span><span class="op">,</span><br />
+<a class="lnum" href="#42" name="42">0042</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'false'</span><span class="op">:</span>&#0160;<span class="name">False</span><span class="op">,</span><br />
+<a class="lnum" href="#43" name="43">0043</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'null'</span><span class="op">:</span>&#0160;<span class="name">None</span><span class="op">,</span><br />
+<a class="lnum" href="#44" name="44">0044</a><span class="op">}</span><br />
+<a class="lnum" href="#45" name="45">0045</a><br />
+<a class="lnum" href="#46" name="46">0046</a><span class="keyword">def</span>&#0160;<span class="name">JSONConstant</span><span class="op">(</span><span class="name">match</span><span class="op">,</span>&#0160;<span class="name">context</span><span class="op">,</span>&#0160;<span class="name">c</span><span class="op">=</span><span class="name">_CONSTANTS</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#47" name="47">0047</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">c</span><span class="op">[</span><span class="name">match</span><span class="op">.</span><span class="name">group</span><span class="op">(</span><span class="number">0</span><span class="op">)</span><span class="op">]</span><span class="op">,</span>&#0160;<span class="name">None</span><br />
+<a class="lnum" href="#48" name="48">0048</a><span class="name">pattern</span><span class="op">(</span><span class="string">'(-?Infinity|NaN|true|false|null)'</span><span class="op">)</span><span class="op">(</span><span class="name">JSONConstant</span><span class="op">)</span><br />
+<a class="lnum" href="#49" name="49">0049</a><br />
+<a class="lnum" href="#50" name="50">0050</a><span class="keyword">def</span>&#0160;<span class="name">JSONNumber</span><span class="op">(</span><span class="name">match</span><span class="op">,</span>&#0160;<span class="name">context</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#51" name="51">0051</a>&#0160;&#0160;&#0160;&#0160;<span class="name">match</span>&#0160;<span class="op">=</span>&#0160;<span class="name">JSONNumber</span><span class="op">.</span><span class="name">regex</span><span class="op">.</span><span class="name">match</span><span class="op">(</span><span class="name">match</span><span class="op">.</span><span class="name">string</span><span class="op">,</span>&#0160;<span class="op">*</span><span class="name">match</span><span class="op">.</span><span class="name">span</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#52" name="52">0052</a>&#0160;&#0160;&#0160;&#0160;<span class="name">integer</span><span class="op">,</span>&#0160;<span class="name">frac</span><span class="op">,</span>&#0160;<span class="name">exp</span>&#0160;<span class="op">=</span>&#0160;<span class="name">match</span><span class="op">.</span><span class="name">groups</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#53" name="53">0053</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">frac</span>&#0160;<span class="keyword">or</span>&#0160;<span class="name">exp</span><span class="op">:</span><br />
+<a class="lnum" href="#54" name="54">0054</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">res</span>&#0160;<span class="op">=</span>&#0160;<span class="name">float</span><span class="op">(</span><span class="name">integer</span>&#0160;<span class="op">+</span>&#0160;<span class="op">(</span><span class="name">frac</span>&#0160;<span class="keyword">or</span>&#0160;<span class="string">''</span><span class="op">)</span>&#0160;<span class="op">+</span>&#0160;<span class="op">(</span><span class="name">exp</span>&#0160;<span class="keyword">or</span>&#0160;<span class="string">''</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#55" name="55">0055</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#56" name="56">0056</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">res</span>&#0160;<span class="op">=</span>&#0160;<span class="name">int</span><span class="op">(</span><span class="name">integer</span><span class="op">)</span><br />
+<a class="lnum" href="#57" name="57">0057</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">res</span><span class="op">,</span>&#0160;<span class="name">None</span><br />
+<a class="lnum" href="#58" name="58">0058</a><span class="name">pattern</span><span class="op">(</span><span class="string">r'(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?'</span><span class="op">)</span><span class="op">(</span><span class="name">JSONNumber</span><span class="op">)</span><br />
+<a class="lnum" href="#59" name="59">0059</a><br />
+<a class="lnum" href="#60" name="60">0060</a><span class="name">STRINGCHUNK</span>&#0160;<span class="op">=</span>&#0160;<span class="name">re</span><span class="op">.</span><span class="name">compile</span><span class="op">(</span><span class="string">r'(.*?)(["\\])'</span><span class="op">,</span>&#0160;<span class="name">FLAGS</span><span class="op">)</span><br />
+<a class="lnum" href="#61" name="61">0061</a><span class="name">BACKSLASH</span>&#0160;<span class="op">=</span>&#0160;<span class="op">{</span><br />
+<a class="lnum" href="#62" name="62">0062</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'"'</span><span class="op">:</span>&#0160;<span class="string">u'"'</span><span class="op">,</span>&#0160;<span class="string">'\\'</span><span class="op">:</span>&#0160;<span class="string">u'\\'</span><span class="op">,</span>&#0160;<span class="string">'/'</span><span class="op">:</span>&#0160;<span class="string">u'/'</span><span class="op">,</span><br />
+<a class="lnum" href="#63" name="63">0063</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'b'</span><span class="op">:</span>&#0160;<span class="string">u'\b'</span><span class="op">,</span>&#0160;<span class="string">'f'</span><span class="op">:</span>&#0160;<span class="string">u'\f'</span><span class="op">,</span>&#0160;<span class="string">'n'</span><span class="op">:</span>&#0160;<span class="string">u'\n'</span><span class="op">,</span>&#0160;<span class="string">'r'</span><span class="op">:</span>&#0160;<span class="string">u'\r'</span><span class="op">,</span>&#0160;<span class="string">'t'</span><span class="op">:</span>&#0160;<span class="string">u'\t'</span><span class="op">,</span><br />
+<a class="lnum" href="#64" name="64">0064</a><span class="op">}</span><br />
+<a class="lnum" href="#65" name="65">0065</a><br />
+<a class="lnum" href="#66" name="66">0066</a><span class="name">DEFAULT_ENCODING</span>&#0160;<span class="op">=</span>&#0160;<span class="string">"utf-8"</span><br />
+<a class="lnum" href="#67" name="67">0067</a><br />
+<a class="lnum" href="#68" name="68">0068</a><span class="keyword">def</span>&#0160;<span class="name">scanstring</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">,</span>&#0160;<span class="name">encoding</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="name">_b</span><span class="op">=</span><span class="name">BACKSLASH</span><span class="op">,</span>&#0160;<span class="name">_m</span><span class="op">=</span><span class="name">STRINGCHUNK</span><span class="op">.</span><span class="name">match</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#69" name="69">0069</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">encoding</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#70" name="70">0070</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">encoding</span>&#0160;<span class="op">=</span>&#0160;<span class="name">DEFAULT_ENCODING</span><br />
+<a class="lnum" href="#71" name="71">0071</a>&#0160;&#0160;&#0160;&#0160;<span class="name">chunks</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="op">]</span><br />
+<a class="lnum" href="#72" name="72">0072</a>&#0160;&#0160;&#0160;&#0160;<span class="name">_append</span>&#0160;<span class="op">=</span>&#0160;<span class="name">chunks</span><span class="op">.</span><span class="name">append</span><br />
+<a class="lnum" href="#73" name="73">0073</a>&#0160;&#0160;&#0160;&#0160;<span class="name">begin</span>&#0160;<span class="op">=</span>&#0160;<span class="name">end</span>&#0160;<span class="op">-</span>&#0160;<span class="number">1</span><br />
+<a class="lnum" href="#74" name="74">0074</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">while</span>&#0160;<span class="number">1</span><span class="op">:</span><br />
+<a class="lnum" href="#75" name="75">0075</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">chunk</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_m</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><br />
+<a class="lnum" href="#76" name="76">0076</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">chunk</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#77" name="77">0077</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><br />
+<a class="lnum" href="#78" name="78">0078</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">errmsg</span><span class="op">(</span><span class="string">"Unterminated&#0160;string&#0160;starting&#0160;at"</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">,</span>&#0160;<span class="name">begin</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#79" name="79">0079</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">chunk</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#80" name="80">0080</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">content</span><span class="op">,</span>&#0160;<span class="name">terminator</span>&#0160;<span class="op">=</span>&#0160;<span class="name">chunk</span><span class="op">.</span><span class="name">groups</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#81" name="81">0081</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">content</span><span class="op">:</span><br />
+<a class="lnum" href="#82" name="82">0082</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">isinstance</span><span class="op">(</span><span class="name">content</span><span class="op">,</span>&#0160;<span class="name">unicode</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#83" name="83">0083</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">content</span>&#0160;<span class="op">=</span>&#0160;<span class="name">unicode</span><span class="op">(</span><span class="name">content</span><span class="op">,</span>&#0160;<span class="name">encoding</span><span class="op">)</span><br />
+<a class="lnum" href="#84" name="84">0084</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">_append</span><span class="op">(</span><span class="name">content</span><span class="op">)</span><br />
+<a class="lnum" href="#85" name="85">0085</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">terminator</span>&#0160;<span class="op">==</span>&#0160;<span class="string">'"'</span><span class="op">:</span><br />
+<a class="lnum" href="#86" name="86">0086</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">break</span><br />
+<a class="lnum" href="#87" name="87">0087</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">try</span><span class="op">:</span><br />
+<a class="lnum" href="#88" name="88">0088</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">esc</span>&#0160;<span class="op">=</span>&#0160;<span class="name">s</span><span class="op">[</span><span class="name">end</span><span class="op">]</span><br />
+<a class="lnum" href="#89" name="89">0089</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">except</span>&#0160;<span class="name">IndexError</span><span class="op">:</span><br />
+<a class="lnum" href="#90" name="90">0090</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><br />
+<a class="lnum" href="#91" name="91">0091</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">errmsg</span><span class="op">(</span><span class="string">"Unterminated&#0160;string&#0160;starting&#0160;at"</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">,</span>&#0160;<span class="name">begin</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#92" name="92">0092</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">esc</span>&#0160;<span class="op">!=</span>&#0160;<span class="string">'u'</span><span class="op">:</span><br />
+<a class="lnum" href="#93" name="93">0093</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">try</span><span class="op">:</span><br />
+<a class="lnum" href="#94" name="94">0094</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">m</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_b</span><span class="op">[</span><span class="name">esc</span><span class="op">]</span><br />
+<a class="lnum" href="#95" name="95">0095</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">except</span>&#0160;<span class="name">KeyError</span><span class="op">:</span><br />
+<a class="lnum" href="#96" name="96">0096</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><br />
+<a class="lnum" href="#97" name="97">0097</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">errmsg</span><span class="op">(</span><span class="string">"Invalid&#0160;\\escape:&#0160;%r"</span>&#0160;<span class="op">%</span>&#0160;<span class="op">(</span><span class="name">esc</span><span class="op">,</span><span class="op">)</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#98" name="98">0098</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">+=</span>&#0160;<span class="number">1</span><br />
+<a class="lnum" href="#99" name="99">0099</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#100" name="100">0100</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">esc</span>&#0160;<span class="op">=</span>&#0160;<span class="name">s</span><span class="op">[</span><span class="name">end</span>&#0160;<span class="op">+</span>&#0160;<span class="number">1</span><span class="op">:</span><span class="name">end</span>&#0160;<span class="op">+</span>&#0160;<span class="number">5</span><span class="op">]</span><br />
+<a class="lnum" href="#101" name="101">0101</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">try</span><span class="op">:</span><br />
+<a class="lnum" href="#102" name="102">0102</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">m</span>&#0160;<span class="op">=</span>&#0160;<span class="name">unichr</span><span class="op">(</span><span class="name">int</span><span class="op">(</span><span class="name">esc</span><span class="op">,</span>&#0160;<span class="number">16</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#103" name="103">0103</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">len</span><span class="op">(</span><span class="name">esc</span><span class="op">)</span>&#0160;<span class="op">!=</span>&#0160;<span class="number">4</span>&#0160;<span class="keyword">or</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">esc</span><span class="op">.</span><span class="name">isalnum</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#104" name="104">0104</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><br />
+<a class="lnum" href="#105" name="105">0105</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">except</span>&#0160;<span class="name">ValueError</span><span class="op">:</span><br />
+<a class="lnum" href="#106" name="106">0106</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><span class="name">errmsg</span><span class="op">(</span><span class="string">"Invalid&#0160;\\uXXXX&#0160;escape"</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#107" name="107">0107</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">+=</span>&#0160;<span class="number">5</span><br />
+<a class="lnum" href="#108" name="108">0108</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">_append</span><span class="op">(</span><span class="name">m</span><span class="op">)</span><br />
+<a class="lnum" href="#109" name="109">0109</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="string">u''</span><span class="op">.</span><span class="name">join</span><span class="op">(</span><span class="name">chunks</span><span class="op">)</span><span class="op">,</span>&#0160;<span class="name">end</span><br />
+<a class="lnum" href="#110" name="110">0110</a><br />
+<a class="lnum" href="#111" name="111">0111</a><span class="keyword">def</span>&#0160;<span class="name">JSONString</span><span class="op">(</span><span class="name">match</span><span class="op">,</span>&#0160;<span class="name">context</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#112" name="112">0112</a>&#0160;&#0160;&#0160;&#0160;<span class="name">encoding</span>&#0160;<span class="op">=</span>&#0160;<span class="name">getattr</span><span class="op">(</span><span class="name">context</span><span class="op">,</span>&#0160;<span class="string">'encoding'</span><span class="op">,</span>&#0160;<span class="name">None</span><span class="op">)</span><br />
+<a class="lnum" href="#113" name="113">0113</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">scanstring</span><span class="op">(</span><span class="name">match</span><span class="op">.</span><span class="name">string</span><span class="op">,</span>&#0160;<span class="name">match</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><span class="op">,</span>&#0160;<span class="name">encoding</span><span class="op">)</span><br />
+<a class="lnum" href="#114" name="114">0114</a><span class="name">pattern</span><span class="op">(</span><span class="string">r'"'</span><span class="op">)</span><span class="op">(</span><span class="name">JSONString</span><span class="op">)</span><br />
+<a class="lnum" href="#115" name="115">0115</a><br />
+<a class="lnum" href="#116" name="116">0116</a><span class="name">WHITESPACE</span>&#0160;<span class="op">=</span>&#0160;<span class="name">re</span><span class="op">.</span><span class="name">compile</span><span class="op">(</span><span class="string">r'\s*'</span><span class="op">,</span>&#0160;<span class="name">FLAGS</span><span class="op">)</span><br />
+<a class="lnum" href="#117" name="117">0117</a><br />
+<a class="lnum" href="#118" name="118">0118</a><span class="keyword">def</span>&#0160;<span class="name">JSONObject</span><span class="op">(</span><span class="name">match</span><span class="op">,</span>&#0160;<span class="name">context</span><span class="op">,</span>&#0160;<span class="name">_w</span><span class="op">=</span><span class="name">WHITESPACE</span><span class="op">.</span><span class="name">match</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#119" name="119">0119</a>&#0160;&#0160;&#0160;&#0160;<span class="name">pairs</span>&#0160;<span class="op">=</span>&#0160;<span class="op">{</span><span class="op">}</span><br />
+<a class="lnum" href="#120" name="120">0120</a>&#0160;&#0160;&#0160;&#0160;<span class="name">s</span>&#0160;<span class="op">=</span>&#0160;<span class="name">match</span><span class="op">.</span><span class="name">string</span><br />
+<a class="lnum" href="#121" name="121">0121</a>&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_w</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">match</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#122" name="122">0122</a>&#0160;&#0160;&#0160;&#0160;<span class="name">nextchar</span>&#0160;<span class="op">=</span>&#0160;<span class="name">s</span><span class="op">[</span><span class="name">end</span><span class="op">:</span><span class="name">end</span>&#0160;<span class="op">+</span>&#0160;<span class="number">1</span><span class="op">]</span><br />
+<a class="lnum" href="#123" name="123">0123</a>&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;trivial&#0160;empty&#0160;object</span><br />
+<a class="lnum" href="#124" name="124">0124</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">nextchar</span>&#0160;<span class="op">==</span>&#0160;<span class="string">'}'</span><span class="op">:</span><br />
+<a class="lnum" href="#125" name="125">0125</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">pairs</span><span class="op">,</span>&#0160;<span class="name">end</span>&#0160;<span class="op">+</span>&#0160;<span class="number">1</span><br />
+<a class="lnum" href="#126" name="126">0126</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">nextchar</span>&#0160;<span class="op">!=</span>&#0160;<span class="string">'"'</span><span class="op">:</span><br />
+<a class="lnum" href="#127" name="127">0127</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><span class="name">errmsg</span><span class="op">(</span><span class="string">"Expecting&#0160;property&#0160;name"</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#128" name="128">0128</a>&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">+=</span>&#0160;<span class="number">1</span><br />
+<a class="lnum" href="#129" name="129">0129</a>&#0160;&#0160;&#0160;&#0160;<span class="name">encoding</span>&#0160;<span class="op">=</span>&#0160;<span class="name">getattr</span><span class="op">(</span><span class="name">context</span><span class="op">,</span>&#0160;<span class="string">'encoding'</span><span class="op">,</span>&#0160;<span class="name">None</span><span class="op">)</span><br />
+<a class="lnum" href="#130" name="130">0130</a>&#0160;&#0160;&#0160;&#0160;<span class="name">iterscan</span>&#0160;<span class="op">=</span>&#0160;<span class="name">JSONScanner</span><span class="op">.</span><span class="name">iterscan</span><br />
+<a class="lnum" href="#131" name="131">0131</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">while</span>&#0160;<span class="name">True</span><span class="op">:</span><br />
+<a class="lnum" href="#132" name="132">0132</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">key</span><span class="op">,</span>&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">scanstring</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">,</span>&#0160;<span class="name">encoding</span><span class="op">)</span><br />
+<a class="lnum" href="#133" name="133">0133</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_w</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#134" name="134">0134</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">s</span><span class="op">[</span><span class="name">end</span><span class="op">:</span><span class="name">end</span>&#0160;<span class="op">+</span>&#0160;<span class="number">1</span><span class="op">]</span>&#0160;<span class="op">!=</span>&#0160;<span class="string">':'</span><span class="op">:</span><br />
+<a class="lnum" href="#135" name="135">0135</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><span class="name">errmsg</span><span class="op">(</span><span class="string">"Expecting&#0160;:&#0160;delimiter"</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#136" name="136">0136</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_w</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span>&#0160;<span class="op">+</span>&#0160;<span class="number">1</span><span class="op">)</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#137" name="137">0137</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">try</span><span class="op">:</span><br />
+<a class="lnum" href="#138" name="138">0138</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">value</span><span class="op">,</span>&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">iterscan</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">idx</span><span class="op">=</span><span class="name">end</span><span class="op">,</span>&#0160;<span class="name">context</span><span class="op">=</span><span class="name">context</span><span class="op">)</span><span class="op">.</span><span class="name">next</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#139" name="139">0139</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">except</span>&#0160;<span class="name">StopIteration</span><span class="op">:</span><br />
+<a class="lnum" href="#140" name="140">0140</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><span class="name">errmsg</span><span class="op">(</span><span class="string">"Expecting&#0160;object"</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#141" name="141">0141</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">pairs</span><span class="op">[</span><span class="name">key</span><span class="op">]</span>&#0160;<span class="op">=</span>&#0160;<span class="name">value</span><br />
+<a class="lnum" href="#142" name="142">0142</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_w</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#143" name="143">0143</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">nextchar</span>&#0160;<span class="op">=</span>&#0160;<span class="name">s</span><span class="op">[</span><span class="name">end</span><span class="op">:</span><span class="name">end</span>&#0160;<span class="op">+</span>&#0160;<span class="number">1</span><span class="op">]</span><br />
+<a class="lnum" href="#144" name="144">0144</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">+=</span>&#0160;<span class="number">1</span><br />
+<a class="lnum" href="#145" name="145">0145</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">nextchar</span>&#0160;<span class="op">==</span>&#0160;<span class="string">'}'</span><span class="op">:</span><br />
+<a class="lnum" href="#146" name="146">0146</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">break</span><br />
+<a class="lnum" href="#147" name="147">0147</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">nextchar</span>&#0160;<span class="op">!=</span>&#0160;<span class="string">','</span><span class="op">:</span><br />
+<a class="lnum" href="#148" name="148">0148</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><span class="name">errmsg</span><span class="op">(</span><span class="string">"Expecting&#0160;,&#0160;delimiter"</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span>&#0160;<span class="op">-</span>&#0160;<span class="number">1</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#149" name="149">0149</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_w</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#150" name="150">0150</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">nextchar</span>&#0160;<span class="op">=</span>&#0160;<span class="name">s</span><span class="op">[</span><span class="name">end</span><span class="op">:</span><span class="name">end</span>&#0160;<span class="op">+</span>&#0160;<span class="number">1</span><span class="op">]</span><br />
+<a class="lnum" href="#151" name="151">0151</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">+=</span>&#0160;<span class="number">1</span><br />
+<a class="lnum" href="#152" name="152">0152</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">nextchar</span>&#0160;<span class="op">!=</span>&#0160;<span class="string">'"'</span><span class="op">:</span><br />
+<a class="lnum" href="#153" name="153">0153</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><span class="name">errmsg</span><span class="op">(</span><span class="string">"Expecting&#0160;property&#0160;name"</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span>&#0160;<span class="op">-</span>&#0160;<span class="number">1</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#154" name="154">0154</a>&#0160;&#0160;&#0160;&#0160;<span class="name">object_hook</span>&#0160;<span class="op">=</span>&#0160;<span class="name">getattr</span><span class="op">(</span><span class="name">context</span><span class="op">,</span>&#0160;<span class="string">'object_hook'</span><span class="op">,</span>&#0160;<span class="name">None</span><span class="op">)</span><br />
+<a class="lnum" href="#155" name="155">0155</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">object_hook</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#156" name="156">0156</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">pairs</span>&#0160;<span class="op">=</span>&#0160;<span class="name">object_hook</span><span class="op">(</span><span class="name">pairs</span><span class="op">)</span><br />
+<a class="lnum" href="#157" name="157">0157</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">pairs</span><span class="op">,</span>&#0160;<span class="name">end</span><br />
+<a class="lnum" href="#158" name="158">0158</a><span class="name">pattern</span><span class="op">(</span><span class="string">r'{'</span><span class="op">)</span><span class="op">(</span><span class="name">JSONObject</span><span class="op">)</span><br />
+<a class="lnum" href="#159" name="159">0159</a><br />
+<a class="lnum" href="#160" name="160">0160</a><span class="keyword">def</span>&#0160;<span class="name">JSONArray</span><span class="op">(</span><span class="name">match</span><span class="op">,</span>&#0160;<span class="name">context</span><span class="op">,</span>&#0160;<span class="name">_w</span><span class="op">=</span><span class="name">WHITESPACE</span><span class="op">.</span><span class="name">match</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#161" name="161">0161</a>&#0160;&#0160;&#0160;&#0160;<span class="name">values</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="op">]</span><br />
+<a class="lnum" href="#162" name="162">0162</a>&#0160;&#0160;&#0160;&#0160;<span class="name">s</span>&#0160;<span class="op">=</span>&#0160;<span class="name">match</span><span class="op">.</span><span class="name">string</span><br />
+<a class="lnum" href="#163" name="163">0163</a>&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_w</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">match</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#164" name="164">0164</a>&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;look-ahead&#0160;for&#0160;trivial&#0160;empty&#0160;array</span><br />
+<a class="lnum" href="#165" name="165">0165</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;<span class="name">nextchar</span>&#0160;<span class="op">=</span>&#0160;<span class="name">s</span><span class="op">[</span><span class="name">end</span><span class="op">:</span><span class="name">end</span>&#0160;<span class="op">+</span>&#0160;<span class="number">1</span><span class="op">]</span><br />
+<a class="lnum" href="#166" name="166">0166</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">nextchar</span>&#0160;<span class="op">==</span>&#0160;<span class="string">']'</span><span class="op">:</span><br />
+<a class="lnum" href="#167" name="167">0167</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">values</span><span class="op">,</span>&#0160;<span class="name">end</span>&#0160;<span class="op">+</span>&#0160;<span class="number">1</span><br />
+<a class="lnum" href="#168" name="168">0168</a>&#0160;&#0160;&#0160;&#0160;<span class="name">iterscan</span>&#0160;<span class="op">=</span>&#0160;<span class="name">JSONScanner</span><span class="op">.</span><span class="name">iterscan</span><br />
+<a class="lnum" href="#169" name="169">0169</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">while</span>&#0160;<span class="name">True</span><span class="op">:</span><br />
+<a class="lnum" href="#170" name="170">0170</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">try</span><span class="op">:</span><br />
+<a class="lnum" href="#171" name="171">0171</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">value</span><span class="op">,</span>&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">iterscan</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">idx</span><span class="op">=</span><span class="name">end</span><span class="op">,</span>&#0160;<span class="name">context</span><span class="op">=</span><span class="name">context</span><span class="op">)</span><span class="op">.</span><span class="name">next</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#172" name="172">0172</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">except</span>&#0160;<span class="name">StopIteration</span><span class="op">:</span><br />
+<a class="lnum" href="#173" name="173">0173</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><span class="name">errmsg</span><span class="op">(</span><span class="string">"Expecting&#0160;object"</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#174" name="174">0174</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">values</span><span class="op">.</span><span class="name">append</span><span class="op">(</span><span class="name">value</span><span class="op">)</span><br />
+<a class="lnum" href="#175" name="175">0175</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_w</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#176" name="176">0176</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">nextchar</span>&#0160;<span class="op">=</span>&#0160;<span class="name">s</span><span class="op">[</span><span class="name">end</span><span class="op">:</span><span class="name">end</span>&#0160;<span class="op">+</span>&#0160;<span class="number">1</span><span class="op">]</span><br />
+<a class="lnum" href="#177" name="177">0177</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">+=</span>&#0160;<span class="number">1</span><br />
+<a class="lnum" href="#178" name="178">0178</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">nextchar</span>&#0160;<span class="op">==</span>&#0160;<span class="string">']'</span><span class="op">:</span><br />
+<a class="lnum" href="#179" name="179">0179</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">break</span><br />
+<a class="lnum" href="#180" name="180">0180</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">nextchar</span>&#0160;<span class="op">!=</span>&#0160;<span class="string">','</span><span class="op">:</span><br />
+<a class="lnum" href="#181" name="181">0181</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><span class="name">errmsg</span><span class="op">(</span><span class="string">"Expecting&#0160;,&#0160;delimiter"</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#182" name="182">0182</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_w</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#183" name="183">0183</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">values</span><span class="op">,</span>&#0160;<span class="name">end</span><br />
+<a class="lnum" href="#184" name="184">0184</a><span class="name">pattern</span><span class="op">(</span><span class="string">r'\['</span><span class="op">)</span><span class="op">(</span><span class="name">JSONArray</span><span class="op">)</span><br />
+<a class="lnum" href="#185" name="185">0185</a><br />
+<a class="lnum" href="#186" name="186">0186</a><span class="name">ANYTHING</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><br />
+<a class="lnum" href="#187" name="187">0187</a>&#0160;&#0160;&#0160;&#0160;<span class="name">JSONObject</span><span class="op">,</span><br />
+<a class="lnum" href="#188" name="188">0188</a>&#0160;&#0160;&#0160;&#0160;<span class="name">JSONArray</span><span class="op">,</span><br />
+<a class="lnum" href="#189" name="189">0189</a>&#0160;&#0160;&#0160;&#0160;<span class="name">JSONString</span><span class="op">,</span><br />
+<a class="lnum" href="#190" name="190">0190</a>&#0160;&#0160;&#0160;&#0160;<span class="name">JSONConstant</span><span class="op">,</span><br />
+<a class="lnum" href="#191" name="191">0191</a>&#0160;&#0160;&#0160;&#0160;<span class="name">JSONNumber</span><span class="op">,</span><br />
+<a class="lnum" href="#192" name="192">0192</a><span class="op">]</span><br />
+<a class="lnum" href="#193" name="193">0193</a><br />
+<a class="lnum" href="#194" name="194">0194</a><span class="name">JSONScanner</span>&#0160;<span class="op">=</span>&#0160;<span class="name">Scanner</span><span class="op">(</span><span class="name">ANYTHING</span><span class="op">)</span><br />
+<a class="lnum" href="#195" name="195">0195</a><br />
+<a class="lnum" href="#196" name="196">0196</a><span class="keyword">class</span>&#0160;<span class="name">JSONDecoder</span><span class="op">(</span><span class="name">object</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#197" name="197">0197</a>&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#198" name="198">0198</a><span class="string">&#0160;&#0160;&#0160;&#0160;Simple&#0160;JSON&#0160;&lt;http://json.org&gt;&#0160;decoder</span><br />
+<a class="lnum" href="#199" name="199">0199</a><span class="string"></span><br />
+<a class="lnum" href="#200" name="200">0200</a><span class="string">&#0160;&#0160;&#0160;&#0160;Performs&#0160;the&#0160;following&#0160;translations&#0160;in&#0160;decoding:</span><br />
+<a class="lnum" href="#201" name="201">0201</a><span class="string">&#0160;&#0160;&#0160;&#0160;</span><br />
+<a class="lnum" href="#202" name="202">0202</a><span class="string">&#0160;&#0160;&#0160;&#0160;+---------------+-------------------+</span><br />
+<a class="lnum" href="#203" name="203">0203</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;JSON&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|&#0160;Python&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#204" name="204">0204</a><span class="string">&#0160;&#0160;&#0160;&#0160;+===============+===================+</span><br />
+<a class="lnum" href="#205" name="205">0205</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;object&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|&#0160;dict&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#206" name="206">0206</a><span class="string">&#0160;&#0160;&#0160;&#0160;+---------------+-------------------+</span><br />
+<a class="lnum" href="#207" name="207">0207</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;array&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|&#0160;list&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#208" name="208">0208</a><span class="string">&#0160;&#0160;&#0160;&#0160;+---------------+-------------------+</span><br />
+<a class="lnum" href="#209" name="209">0209</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;string&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|&#0160;unicode&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#210" name="210">0210</a><span class="string">&#0160;&#0160;&#0160;&#0160;+---------------+-------------------+</span><br />
+<a class="lnum" href="#211" name="211">0211</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;number&#0160;(int)&#0160;&#0160;|&#0160;int,&#0160;long&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#212" name="212">0212</a><span class="string">&#0160;&#0160;&#0160;&#0160;+---------------+-------------------+</span><br />
+<a class="lnum" href="#213" name="213">0213</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;number&#0160;(real)&#0160;|&#0160;float&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#214" name="214">0214</a><span class="string">&#0160;&#0160;&#0160;&#0160;+---------------+-------------------+</span><br />
+<a class="lnum" href="#215" name="215">0215</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;true&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|&#0160;True&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#216" name="216">0216</a><span class="string">&#0160;&#0160;&#0160;&#0160;+---------------+-------------------+</span><br />
+<a class="lnum" href="#217" name="217">0217</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;false&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|&#0160;False&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#218" name="218">0218</a><span class="string">&#0160;&#0160;&#0160;&#0160;+---------------+-------------------+</span><br />
+<a class="lnum" href="#219" name="219">0219</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;null&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|&#0160;None&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#220" name="220">0220</a><span class="string">&#0160;&#0160;&#0160;&#0160;+---------------+-------------------+</span><br />
+<a class="lnum" href="#221" name="221">0221</a><span class="string"></span><br />
+<a class="lnum" href="#222" name="222">0222</a><span class="string">&#0160;&#0160;&#0160;&#0160;It&#0160;also&#0160;understands&#0160;``NaN``,&#0160;``Infinity``,&#0160;and&#0160;``-Infinity``&#0160;as</span><br />
+<a class="lnum" href="#223" name="223">0223</a><span class="string">&#0160;&#0160;&#0160;&#0160;their&#0160;corresponding&#0160;``float``&#0160;values,&#0160;which&#0160;is&#0160;outside&#0160;the&#0160;JSON&#0160;spec.</span><br />
+<a class="lnum" href="#224" name="224">0224</a><span class="string">&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#225" name="225">0225</a><br />
+<a class="lnum" href="#226" name="226">0226</a>&#0160;&#0160;&#0160;&#0160;<span class="name">_scanner</span>&#0160;<span class="op">=</span>&#0160;<span class="name">Scanner</span><span class="op">(</span><span class="name">ANYTHING</span><span class="op">)</span><br />
+<a class="lnum" href="#227" name="227">0227</a>&#0160;&#0160;&#0160;&#0160;<span class="name">__all__</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="string">'__init__'</span><span class="op">,</span>&#0160;<span class="string">'decode'</span><span class="op">,</span>&#0160;<span class="string">'raw_decode'</span><span class="op">]</span><br />
+<a class="lnum" href="#228" name="228">0228</a><br />
+<a class="lnum" href="#229" name="229">0229</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__init__</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">encoding</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="name">object_hook</span><span class="op">=</span><span class="name">None</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#230" name="230">0230</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#231" name="231">0231</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;``encoding``&#0160;determines&#0160;the&#0160;encoding&#0160;used&#0160;to&#0160;interpret&#0160;any&#0160;``str``</span><br />
+<a class="lnum" href="#232" name="232">0232</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;objects&#0160;decoded&#0160;by&#0160;this&#0160;instance&#0160;(utf-8&#0160;by&#0160;default).&#0160;&#0160;It&#0160;has&#0160;no</span><br />
+<a class="lnum" href="#233" name="233">0233</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;effect&#0160;when&#0160;decoding&#0160;``unicode``&#0160;objects.</span><br />
+<a class="lnum" href="#234" name="234">0234</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;</span><br />
+<a class="lnum" href="#235" name="235">0235</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;Note&#0160;that&#0160;currently&#0160;only&#0160;encodings&#0160;that&#0160;are&#0160;a&#0160;superset&#0160;of&#0160;ASCII&#0160;work,</span><br />
+<a class="lnum" href="#236" name="236">0236</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;strings&#0160;of&#0160;other&#0160;encodings&#0160;should&#0160;be&#0160;passed&#0160;in&#0160;as&#0160;``unicode``.</span><br />
+<a class="lnum" href="#237" name="237">0237</a><span class="string"></span><br />
+<a class="lnum" href="#238" name="238">0238</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;``object_hook``,&#0160;if&#0160;specified,&#0160;will&#0160;be&#0160;called&#0160;with&#0160;the&#0160;result</span><br />
+<a class="lnum" href="#239" name="239">0239</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;of&#0160;every&#0160;JSON&#0160;object&#0160;decoded&#0160;and&#0160;its&#0160;return&#0160;value&#0160;will&#0160;be&#0160;used&#0160;in</span><br />
+<a class="lnum" href="#240" name="240">0240</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;place&#0160;of&#0160;the&#0160;given&#0160;``dict``.&#0160;&#0160;This&#0160;can&#0160;be&#0160;used&#0160;to&#0160;provide&#0160;custom</span><br />
+<a class="lnum" href="#241" name="241">0241</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;deserializations&#0160;(e.g.&#0160;to&#0160;support&#0160;JSON-RPC&#0160;class&#0160;hinting).</span><br />
+<a class="lnum" href="#242" name="242">0242</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#243" name="243">0243</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">encoding</span>&#0160;<span class="op">=</span>&#0160;<span class="name">encoding</span><br />
+<a class="lnum" href="#244" name="244">0244</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">object_hook</span>&#0160;<span class="op">=</span>&#0160;<span class="name">object_hook</span><br />
+<a class="lnum" href="#245" name="245">0245</a><br />
+<a class="lnum" href="#246" name="246">0246</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">decode</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">,</span>&#0160;<span class="name">_w</span><span class="op">=</span><span class="name">WHITESPACE</span><span class="op">.</span><span class="name">match</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#247" name="247">0247</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#248" name="248">0248</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;Return&#0160;the&#0160;Python&#0160;representation&#0160;of&#0160;``s``&#0160;(a&#0160;``str``&#0160;or&#0160;``unicode``</span><br />
+<a class="lnum" href="#249" name="249">0249</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;instance&#0160;containing&#0160;a&#0160;JSON&#0160;document)</span><br />
+<a class="lnum" href="#250" name="250">0250</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#251" name="251">0251</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">obj</span><span class="op">,</span>&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">raw_decode</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">idx</span><span class="op">=</span><span class="name">_w</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="number">0</span><span class="op">)</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#252" name="252">0252</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_w</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">)</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#253" name="253">0253</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">end</span>&#0160;<span class="op">!=</span>&#0160;<span class="name">len</span><span class="op">(</span><span class="name">s</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#254" name="254">0254</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><span class="name">errmsg</span><span class="op">(</span><span class="string">"Extra&#0160;data"</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">,</span>&#0160;<span class="name">end</span><span class="op">,</span>&#0160;<span class="name">len</span><span class="op">(</span><span class="name">s</span><span class="op">)</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#255" name="255">0255</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">obj</span><br />
+<a class="lnum" href="#256" name="256">0256</a><br />
+<a class="lnum" href="#257" name="257">0257</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">raw_decode</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">,</span>&#0160;<span class="op">**</span><span class="name">kw</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#258" name="258">0258</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#259" name="259">0259</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;Decode&#0160;a&#0160;JSON&#0160;document&#0160;from&#0160;``s``&#0160;(a&#0160;``str``&#0160;or&#0160;``unicode``&#0160;beginning</span><br />
+<a class="lnum" href="#260" name="260">0260</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;with&#0160;a&#0160;JSON&#0160;document)&#0160;and&#0160;return&#0160;a&#0160;2-tuple&#0160;of&#0160;the&#0160;Python</span><br />
+<a class="lnum" href="#261" name="261">0261</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;representation&#0160;and&#0160;the&#0160;index&#0160;in&#0160;``s``&#0160;where&#0160;the&#0160;document&#0160;ended.</span><br />
+<a class="lnum" href="#262" name="262">0262</a><span class="string"></span><br />
+<a class="lnum" href="#263" name="263">0263</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;This&#0160;can&#0160;be&#0160;used&#0160;to&#0160;decode&#0160;a&#0160;JSON&#0160;document&#0160;from&#0160;a&#0160;string&#0160;that&#0160;may</span><br />
+<a class="lnum" href="#264" name="264">0264</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;have&#0160;extraneous&#0160;data&#0160;at&#0160;the&#0160;end.</span><br />
+<a class="lnum" href="#265" name="265">0265</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#266" name="266">0266</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">kw</span><span class="op">.</span><span class="name">setdefault</span><span class="op">(</span><span class="string">'context'</span><span class="op">,</span>&#0160;<span class="name">self</span><span class="op">)</span><br />
+<a class="lnum" href="#267" name="267">0267</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">try</span><span class="op">:</span><br />
+<a class="lnum" href="#268" name="268">0268</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">obj</span><span class="op">,</span>&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">_scanner</span><span class="op">.</span><span class="name">iterscan</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="op">**</span><span class="name">kw</span><span class="op">)</span><span class="op">.</span><span class="name">next</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#269" name="269">0269</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">except</span>&#0160;<span class="name">StopIteration</span><span class="op">:</span><br />
+<a class="lnum" href="#270" name="270">0270</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><span class="string">"No&#0160;JSON&#0160;object&#0160;could&#0160;be&#0160;decoded"</span><span class="op">)</span><br />
+<a class="lnum" href="#271" name="271">0271</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">obj</span><span class="op">,</span>&#0160;<span class="name">end</span><br />
+<a class="lnum" href="#272" name="272">0272</a><br />
+<a class="lnum" href="#273" name="273">0273</a><span class="name">__all__</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="string">'JSONDecoder'</span><span class="op">]</span></code></div></body></html>
\ No newline at end of file
diff --git a/src/simplejson/docs/simplejson/encoder.py.html b/src/simplejson/docs/simplejson/encoder.py.html
new file mode 100644 (file)
index 0000000..8c814ab
--- /dev/null
@@ -0,0 +1,443 @@
+<html><head><title>/Users/bob/src/simplejson/simplejson/encoder.py</title>
+        <script type="text/javascript"><!--
+        
+function show_line_range() {
+    var href = document.location.href;
+    if (href.indexOf('?') == -1) {
+        return;
+    }
+    var qs = href.substring(href.indexOf('?')+1);
+    if (qs.indexOf('#') >= 0) {
+        qs = qs.substring(0, qs.indexOf('#'));
+    }
+    var first = qs.match(/f=(\d+)/)[1];
+    var last = qs.match(/l=(\d+)/)[1];
+    if (! first || ! last) {
+        return;
+    }
+    var anchors = document.getElementsByTagName('A');
+    var container = document.createElement('DIV');
+    container.className = 'highlighted';
+    var children = [];
+    var start = null;
+    var parent = null;
+    var highlight = false;
+    for (var i = 0; i < anchors.length; i++) {
+        var el = anchors[i];
+        if (el.getAttribute('name') == first) {
+            start = el.previousSibling;
+            parent = el.parentNode;
+            highlight = true;
+        }
+        if (el.getAttribute('name') == last) {
+            break;
+        }
+        if (highlight) {
+            children[children.length] = el;
+            el = el.nextSibling;
+            while (el && el.tagName != 'A') {
+                children[children.length] = el;
+                el = el.nextSibling;
+            }
+        }
+    }
+    for (i=0; i<children.length; i++) {
+        container.appendChild(children[i]);
+    }
+    if (start) {
+        start.parentNode.insertBefore(container, start.nextSibling);
+    } else {
+        parent.insertBefore(container, parent.childNodes[0]);
+    }
+}
+
+        // --></script>
+        <style>
+        div.python {
+          color: #333
+        }
+        div.python a.lnum {
+          color: #555;
+          background-color: #eee;
+          border-right: 1px solid #999;
+          padding-right: 2px;
+          margin-right: 4px;
+        }
+        div.python span.comment { color: #933 }
+        div.python span.keyword { color: #a3e; font-weight: bold  }
+        div.python span.op { color: #c96 }
+        div.python span.string { color: #6a6 }
+        div.python span.name { }
+        div.python span.text { color: #333 }
+        div.highlighted { background-color: #ff9; border: 1px solid #009 }
+        </style></head><body onload="show_line_range()"><div class="python"><code><a class="lnum" href="#1" name="1">0001</a><span class="string">"""</span><br />
+<a class="lnum" href="#2" name="2">0002</a><span class="string">Implementation&#0160;of&#0160;JSONEncoder</span><br />
+<a class="lnum" href="#3" name="3">0003</a><span class="string">"""</span><br />
+<a class="lnum" href="#4" name="4">0004</a><span class="keyword">import</span>&#0160;<span class="name">re</span><br />
+<a class="lnum" href="#5" name="5">0005</a><span class="keyword">try</span><span class="op">:</span><br />
+<a class="lnum" href="#6" name="6">0006</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">from</span>&#0160;<span class="name">simplejson</span>&#0160;<span class="keyword">import</span>&#0160;<span class="name">_speedups</span><br />
+<a class="lnum" href="#7" name="7">0007</a><span class="keyword">except</span>&#0160;<span class="name">ImportError</span><span class="op">:</span><br />
+<a class="lnum" href="#8" name="8">0008</a>&#0160;&#0160;&#0160;&#0160;<span class="name">_speedups</span>&#0160;<span class="op">=</span>&#0160;<span class="name">None</span><br />
+<a class="lnum" href="#9" name="9">0009</a><br />
+<a class="lnum" href="#10" name="10">0010</a><span class="name">ESCAPE</span>&#0160;<span class="op">=</span>&#0160;<span class="name">re</span><span class="op">.</span><span class="name">compile</span><span class="op">(</span><span class="string">r'[\x00-\x19\\"\b\f\n\r\t]'</span><span class="op">)</span><br />
+<a class="lnum" href="#11" name="11">0011</a><span class="name">ESCAPE_ASCII</span>&#0160;<span class="op">=</span>&#0160;<span class="name">re</span><span class="op">.</span><span class="name">compile</span><span class="op">(</span><span class="string">r'([\\"/]|[^\&#0160;-~])'</span><span class="op">)</span><br />
+<a class="lnum" href="#12" name="12">0012</a><span class="name">ESCAPE_DCT</span>&#0160;<span class="op">=</span>&#0160;<span class="op">{</span><br />
+<a class="lnum" href="#13" name="13">0013</a>&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;escape&#0160;all&#0160;forward&#0160;slashes&#0160;to&#0160;prevent&#0160;&lt;/script&gt;&#0160;attack</span><br />
+<a class="lnum" href="#14" name="14">0014</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'/'</span><span class="op">:</span>&#0160;<span class="string">'\\/'</span><span class="op">,</span><br />
+<a class="lnum" href="#15" name="15">0015</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'\\'</span><span class="op">:</span>&#0160;<span class="string">'\\\\'</span><span class="op">,</span><br />
+<a class="lnum" href="#16" name="16">0016</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'"'</span><span class="op">:</span>&#0160;<span class="string">'\\"'</span><span class="op">,</span><br />
+<a class="lnum" href="#17" name="17">0017</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'\b'</span><span class="op">:</span>&#0160;<span class="string">'\\b'</span><span class="op">,</span><br />
+<a class="lnum" href="#18" name="18">0018</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'\f'</span><span class="op">:</span>&#0160;<span class="string">'\\f'</span><span class="op">,</span><br />
+<a class="lnum" href="#19" name="19">0019</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'\n'</span><span class="op">:</span>&#0160;<span class="string">'\\n'</span><span class="op">,</span><br />
+<a class="lnum" href="#20" name="20">0020</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'\r'</span><span class="op">:</span>&#0160;<span class="string">'\\r'</span><span class="op">,</span><br />
+<a class="lnum" href="#21" name="21">0021</a>&#0160;&#0160;&#0160;&#0160;<span class="string">'\t'</span><span class="op">:</span>&#0160;<span class="string">'\\t'</span><span class="op">,</span><br />
+<a class="lnum" href="#22" name="22">0022</a><span class="op">}</span><br />
+<a class="lnum" href="#23" name="23">0023</a><span class="keyword">for</span>&#0160;<span class="name">i</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">range</span><span class="op">(</span><span class="number">0x20</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#24" name="24">0024</a>&#0160;&#0160;&#0160;&#0160;<span class="name">ESCAPE_DCT</span><span class="op">.</span><span class="name">setdefault</span><span class="op">(</span><span class="name">chr</span><span class="op">(</span><span class="name">i</span><span class="op">)</span><span class="op">,</span>&#0160;<span class="string">'\\u%04x'</span>&#0160;<span class="op">%</span>&#0160;<span class="op">(</span><span class="name">i</span><span class="op">,</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#25" name="25">0025</a><br />
+<a class="lnum" href="#26" name="26">0026</a><span class="comment">#&#0160;assume&#0160;this&#0160;produces&#0160;an&#0160;infinity&#0160;on&#0160;all&#0160;machines&#0160;(probably&#0160;not&#0160;guaranteed)</span><br />
+<a class="lnum" href="#27" name="27">0027</a><span class="comment"></span><span class="name">INFINITY</span>&#0160;<span class="op">=</span>&#0160;<span class="name">float</span><span class="op">(</span><span class="string">'1e66666'</span><span class="op">)</span><br />
+<a class="lnum" href="#28" name="28">0028</a><br />
+<a class="lnum" href="#29" name="29">0029</a><span class="keyword">def</span>&#0160;<span class="name">floatstr</span><span class="op">(</span><span class="name">o</span><span class="op">,</span>&#0160;<span class="name">allow_nan</span><span class="op">=</span><span class="name">True</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#30" name="30">0030</a>&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;Check&#0160;for&#0160;specials.&#0160;&#0160;Note&#0160;that&#0160;this&#0160;type&#0160;of&#0160;test&#0160;is&#0160;processor-&#0160;and/or</span><br />
+<a class="lnum" href="#31" name="31">0031</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;platform-specific,&#0160;so&#0160;do&#0160;tests&#0160;which&#0160;don't&#0160;depend&#0160;on&#0160;the&#0160;internals.</span><br />
+<a class="lnum" href="#32" name="32">0032</a><span class="comment"></span><br />
+<a class="lnum" href="#33" name="33">0033</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">o</span>&#0160;<span class="op">!=</span>&#0160;<span class="name">o</span><span class="op">:</span><br />
+<a class="lnum" href="#34" name="34">0034</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">text</span>&#0160;<span class="op">=</span>&#0160;<span class="string">'NaN'</span><br />
+<a class="lnum" href="#35" name="35">0035</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">o</span>&#0160;<span class="op">==</span>&#0160;<span class="name">INFINITY</span><span class="op">:</span><br />
+<a class="lnum" href="#36" name="36">0036</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">text</span>&#0160;<span class="op">=</span>&#0160;<span class="string">'Infinity'</span><br />
+<a class="lnum" href="#37" name="37">0037</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">o</span>&#0160;<span class="op">==</span>&#0160;<span class="op">-</span><span class="name">INFINITY</span><span class="op">:</span><br />
+<a class="lnum" href="#38" name="38">0038</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">text</span>&#0160;<span class="op">=</span>&#0160;<span class="string">'-Infinity'</span><br />
+<a class="lnum" href="#39" name="39">0039</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#40" name="40">0040</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">str</span><span class="op">(</span><span class="name">o</span><span class="op">)</span><br />
+<a class="lnum" href="#41" name="41">0041</a><br />
+<a class="lnum" href="#42" name="42">0042</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">allow_nan</span><span class="op">:</span><br />
+<a class="lnum" href="#43" name="43">0043</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><span class="string">"Out&#0160;of&#0160;range&#0160;float&#0160;values&#0160;are&#0160;not&#0160;JSON&#0160;compliant:&#0160;%r"</span><br />
+<a class="lnum" href="#44" name="44">0044</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="op">%</span>&#0160;<span class="op">(</span><span class="name">o</span><span class="op">,</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#45" name="45">0045</a><br />
+<a class="lnum" href="#46" name="46">0046</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">text</span><br />
+<a class="lnum" href="#47" name="47">0047</a><br />
+<a class="lnum" href="#48" name="48">0048</a><br />
+<a class="lnum" href="#49" name="49">0049</a><span class="keyword">def</span>&#0160;<span class="name">encode_basestring</span><span class="op">(</span><span class="name">s</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#50" name="50">0050</a>&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#51" name="51">0051</a><span class="string">&#0160;&#0160;&#0160;&#0160;Return&#0160;a&#0160;JSON&#0160;representation&#0160;of&#0160;a&#0160;Python&#0160;string</span><br />
+<a class="lnum" href="#52" name="52">0052</a><span class="string">&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#53" name="53">0053</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">replace</span><span class="op">(</span><span class="name">match</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#54" name="54">0054</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">ESCAPE_DCT</span><span class="op">[</span><span class="name">match</span><span class="op">.</span><span class="name">group</span><span class="op">(</span><span class="number">0</span><span class="op">)</span><span class="op">]</span><br />
+<a class="lnum" href="#55" name="55">0055</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="string">'"'</span>&#0160;<span class="op">+</span>&#0160;<span class="name">ESCAPE</span><span class="op">.</span><span class="name">sub</span><span class="op">(</span><span class="name">replace</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">)</span>&#0160;<span class="op">+</span>&#0160;<span class="string">'"'</span><br />
+<a class="lnum" href="#56" name="56">0056</a><br />
+<a class="lnum" href="#57" name="57">0057</a><span class="keyword">def</span>&#0160;<span class="name">encode_basestring_ascii</span><span class="op">(</span><span class="name">s</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#58" name="58">0058</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">replace</span><span class="op">(</span><span class="name">match</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#59" name="59">0059</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">s</span>&#0160;<span class="op">=</span>&#0160;<span class="name">match</span><span class="op">.</span><span class="name">group</span><span class="op">(</span><span class="number">0</span><span class="op">)</span><br />
+<a class="lnum" href="#60" name="60">0060</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">try</span><span class="op">:</span><br />
+<a class="lnum" href="#61" name="61">0061</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">ESCAPE_DCT</span><span class="op">[</span><span class="name">s</span><span class="op">]</span><br />
+<a class="lnum" href="#62" name="62">0062</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">except</span>&#0160;<span class="name">KeyError</span><span class="op">:</span><br />
+<a class="lnum" href="#63" name="63">0063</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">n</span>&#0160;<span class="op">=</span>&#0160;<span class="name">ord</span><span class="op">(</span><span class="name">s</span><span class="op">)</span><br />
+<a class="lnum" href="#64" name="64">0064</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">n</span>&#0160;<span class="op">&lt;</span>&#0160;<span class="number">0x10000</span><span class="op">:</span><br />
+<a class="lnum" href="#65" name="65">0065</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="string">'\\u%04x'</span>&#0160;<span class="op">%</span>&#0160;<span class="op">(</span><span class="name">n</span><span class="op">,</span><span class="op">)</span><br />
+<a class="lnum" href="#66" name="66">0066</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#67" name="67">0067</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;surrogate&#0160;pair</span><br />
+<a class="lnum" href="#68" name="68">0068</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">n</span>&#0160;<span class="op">-=</span>&#0160;<span class="number">0x10000</span><br />
+<a class="lnum" href="#69" name="69">0069</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">s1</span>&#0160;<span class="op">=</span>&#0160;<span class="number">0xd800</span>&#0160;<span class="op">|</span>&#0160;<span class="op">(</span><span class="op">(</span><span class="name">n</span>&#0160;<span class="op">&gt;&gt;</span>&#0160;<span class="number">10</span><span class="op">)</span>&#0160;<span class="op">&amp;</span>&#0160;<span class="number">0x3ff</span><span class="op">)</span><br />
+<a class="lnum" href="#70" name="70">0070</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">s2</span>&#0160;<span class="op">=</span>&#0160;<span class="number">0xdc00</span>&#0160;<span class="op">|</span>&#0160;<span class="op">(</span><span class="name">n</span>&#0160;<span class="op">&amp;</span>&#0160;<span class="number">0x3ff</span><span class="op">)</span><br />
+<a class="lnum" href="#71" name="71">0071</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="string">'\\u%04x\\u%04x'</span>&#0160;<span class="op">%</span>&#0160;<span class="op">(</span><span class="name">s1</span><span class="op">,</span>&#0160;<span class="name">s2</span><span class="op">)</span><br />
+<a class="lnum" href="#72" name="72">0072</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="string">'"'</span>&#0160;<span class="op">+</span>&#0160;<span class="name">str</span><span class="op">(</span><span class="name">ESCAPE_ASCII</span><span class="op">.</span><span class="name">sub</span><span class="op">(</span><span class="name">replace</span><span class="op">,</span>&#0160;<span class="name">s</span><span class="op">)</span><span class="op">)</span>&#0160;<span class="op">+</span>&#0160;<span class="string">'"'</span><br />
+<a class="lnum" href="#73" name="73">0073</a><br />
+<a class="lnum" href="#74" name="74">0074</a><span class="keyword">try</span><span class="op">:</span><br />
+<a class="lnum" href="#75" name="75">0075</a>&#0160;&#0160;&#0160;&#0160;<span class="name">encode_basestring_ascii</span>&#0160;<span class="op">=</span>&#0160;<span class="name">_speedups</span><span class="op">.</span><span class="name">encode_basestring_ascii</span><br />
+<a class="lnum" href="#76" name="76">0076</a>&#0160;&#0160;&#0160;&#0160;<span class="name">_need_utf8</span>&#0160;<span class="op">=</span>&#0160;<span class="name">True</span><br />
+<a class="lnum" href="#77" name="77">0077</a><span class="keyword">except</span>&#0160;<span class="name">AttributeError</span><span class="op">:</span><br />
+<a class="lnum" href="#78" name="78">0078</a>&#0160;&#0160;&#0160;&#0160;<span class="name">_need_utf8</span>&#0160;<span class="op">=</span>&#0160;<span class="name">False</span><br />
+<a class="lnum" href="#79" name="79">0079</a><br />
+<a class="lnum" href="#80" name="80">0080</a><span class="keyword">class</span>&#0160;<span class="name">JSONEncoder</span><span class="op">(</span><span class="name">object</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#81" name="81">0081</a>&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#82" name="82">0082</a><span class="string">&#0160;&#0160;&#0160;&#0160;Extensible&#0160;JSON&#0160;&lt;http://json.org&gt;&#0160;encoder&#0160;for&#0160;Python&#0160;data&#0160;structures.</span><br />
+<a class="lnum" href="#83" name="83">0083</a><span class="string"></span><br />
+<a class="lnum" href="#84" name="84">0084</a><span class="string">&#0160;&#0160;&#0160;&#0160;Supports&#0160;the&#0160;following&#0160;objects&#0160;and&#0160;types&#0160;by&#0160;default:</span><br />
+<a class="lnum" href="#85" name="85">0085</a><span class="string">&#0160;&#0160;&#0160;&#0160;</span><br />
+<a class="lnum" href="#86" name="86">0086</a><span class="string">&#0160;&#0160;&#0160;&#0160;+-------------------+---------------+</span><br />
+<a class="lnum" href="#87" name="87">0087</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;Python&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|&#0160;JSON&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#88" name="88">0088</a><span class="string">&#0160;&#0160;&#0160;&#0160;+===================+===============+</span><br />
+<a class="lnum" href="#89" name="89">0089</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;dict&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|&#0160;object&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#90" name="90">0090</a><span class="string">&#0160;&#0160;&#0160;&#0160;+-------------------+---------------+</span><br />
+<a class="lnum" href="#91" name="91">0091</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;list,&#0160;tuple&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|&#0160;array&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#92" name="92">0092</a><span class="string">&#0160;&#0160;&#0160;&#0160;+-------------------+---------------+</span><br />
+<a class="lnum" href="#93" name="93">0093</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;str,&#0160;unicode&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|&#0160;string&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#94" name="94">0094</a><span class="string">&#0160;&#0160;&#0160;&#0160;+-------------------+---------------+</span><br />
+<a class="lnum" href="#95" name="95">0095</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;int,&#0160;long,&#0160;float&#0160;&#0160;|&#0160;number&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#96" name="96">0096</a><span class="string">&#0160;&#0160;&#0160;&#0160;+-------------------+---------------+</span><br />
+<a class="lnum" href="#97" name="97">0097</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;True&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|&#0160;true&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#98" name="98">0098</a><span class="string">&#0160;&#0160;&#0160;&#0160;+-------------------+---------------+</span><br />
+<a class="lnum" href="#99" name="99">0099</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;False&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|&#0160;false&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#100" name="100">0100</a><span class="string">&#0160;&#0160;&#0160;&#0160;+-------------------+---------------+</span><br />
+<a class="lnum" href="#101" name="101">0101</a><span class="string">&#0160;&#0160;&#0160;&#0160;|&#0160;None&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|&#0160;null&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;|</span><br />
+<a class="lnum" href="#102" name="102">0102</a><span class="string">&#0160;&#0160;&#0160;&#0160;+-------------------+---------------+</span><br />
+<a class="lnum" href="#103" name="103">0103</a><span class="string"></span><br />
+<a class="lnum" href="#104" name="104">0104</a><span class="string">&#0160;&#0160;&#0160;&#0160;To&#0160;extend&#0160;this&#0160;to&#0160;recognize&#0160;other&#0160;objects,&#0160;subclass&#0160;and&#0160;implement&#0160;a</span><br />
+<a class="lnum" href="#105" name="105">0105</a><span class="string">&#0160;&#0160;&#0160;&#0160;``.default()``&#0160;method&#0160;with&#0160;another&#0160;method&#0160;that&#0160;returns&#0160;a&#0160;serializable</span><br />
+<a class="lnum" href="#106" name="106">0106</a><span class="string">&#0160;&#0160;&#0160;&#0160;object&#0160;for&#0160;``o``&#0160;if&#0160;possible,&#0160;otherwise&#0160;it&#0160;should&#0160;call&#0160;the&#0160;superclass</span><br />
+<a class="lnum" href="#107" name="107">0107</a><span class="string">&#0160;&#0160;&#0160;&#0160;implementation&#0160;(to&#0160;raise&#0160;``TypeError``).</span><br />
+<a class="lnum" href="#108" name="108">0108</a><span class="string">&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#109" name="109">0109</a>&#0160;&#0160;&#0160;&#0160;<span class="name">__all__</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="string">'__init__'</span><span class="op">,</span>&#0160;<span class="string">'default'</span><span class="op">,</span>&#0160;<span class="string">'encode'</span><span class="op">,</span>&#0160;<span class="string">'iterencode'</span><span class="op">]</span><br />
+<a class="lnum" href="#110" name="110">0110</a>&#0160;&#0160;&#0160;&#0160;<span class="name">item_separator</span>&#0160;<span class="op">=</span>&#0160;<span class="string">',&#0160;'</span><br />
+<a class="lnum" href="#111" name="111">0111</a>&#0160;&#0160;&#0160;&#0160;<span class="name">key_separator</span>&#0160;<span class="op">=</span>&#0160;<span class="string">':&#0160;'</span><br />
+<a class="lnum" href="#112" name="112">0112</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__init__</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">skipkeys</span><span class="op">=</span><span class="name">False</span><span class="op">,</span>&#0160;<span class="name">ensure_ascii</span><span class="op">=</span><span class="name">True</span><span class="op">,</span><br />
+<a class="lnum" href="#113" name="113">0113</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">check_circular</span><span class="op">=</span><span class="name">True</span><span class="op">,</span>&#0160;<span class="name">allow_nan</span><span class="op">=</span><span class="name">True</span><span class="op">,</span>&#0160;<span class="name">sort_keys</span><span class="op">=</span><span class="name">False</span><span class="op">,</span><br />
+<a class="lnum" href="#114" name="114">0114</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">indent</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="name">separators</span><span class="op">=</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="name">encoding</span><span class="op">=</span><span class="string">'utf-8'</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#115" name="115">0115</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#116" name="116">0116</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;Constructor&#0160;for&#0160;JSONEncoder,&#0160;with&#0160;sensible&#0160;defaults.</span><br />
+<a class="lnum" href="#117" name="117">0117</a><span class="string"></span><br />
+<a class="lnum" href="#118" name="118">0118</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;If&#0160;skipkeys&#0160;is&#0160;False,&#0160;then&#0160;it&#0160;is&#0160;a&#0160;TypeError&#0160;to&#0160;attempt</span><br />
+<a class="lnum" href="#119" name="119">0119</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;encoding&#0160;of&#0160;keys&#0160;that&#0160;are&#0160;not&#0160;str,&#0160;int,&#0160;long,&#0160;float&#0160;or&#0160;None.&#0160;&#0160;If</span><br />
+<a class="lnum" href="#120" name="120">0120</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;skipkeys&#0160;is&#0160;True,&#0160;such&#0160;items&#0160;are&#0160;simply&#0160;skipped.</span><br />
+<a class="lnum" href="#121" name="121">0121</a><span class="string"></span><br />
+<a class="lnum" href="#122" name="122">0122</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;If&#0160;ensure_ascii&#0160;is&#0160;True,&#0160;the&#0160;output&#0160;is&#0160;guaranteed&#0160;to&#0160;be&#0160;str</span><br />
+<a class="lnum" href="#123" name="123">0123</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;objects&#0160;with&#0160;all&#0160;incoming&#0160;unicode&#0160;characters&#0160;escaped.&#0160;&#0160;If</span><br />
+<a class="lnum" href="#124" name="124">0124</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;ensure_ascii&#0160;is&#0160;false,&#0160;the&#0160;output&#0160;will&#0160;be&#0160;unicode&#0160;object.</span><br />
+<a class="lnum" href="#125" name="125">0125</a><span class="string"></span><br />
+<a class="lnum" href="#126" name="126">0126</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;If&#0160;check_circular&#0160;is&#0160;True,&#0160;then&#0160;lists,&#0160;dicts,&#0160;and&#0160;custom&#0160;encoded</span><br />
+<a class="lnum" href="#127" name="127">0127</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;objects&#0160;will&#0160;be&#0160;checked&#0160;for&#0160;circular&#0160;references&#0160;during&#0160;encoding&#0160;to</span><br />
+<a class="lnum" href="#128" name="128">0128</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;prevent&#0160;an&#0160;infinite&#0160;recursion&#0160;(which&#0160;would&#0160;cause&#0160;an&#0160;OverflowError).</span><br />
+<a class="lnum" href="#129" name="129">0129</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;Otherwise,&#0160;no&#0160;such&#0160;check&#0160;takes&#0160;place.</span><br />
+<a class="lnum" href="#130" name="130">0130</a><span class="string"></span><br />
+<a class="lnum" href="#131" name="131">0131</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;If&#0160;allow_nan&#0160;is&#0160;True,&#0160;then&#0160;NaN,&#0160;Infinity,&#0160;and&#0160;-Infinity&#0160;will&#0160;be</span><br />
+<a class="lnum" href="#132" name="132">0132</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;encoded&#0160;as&#0160;such.&#0160;&#0160;This&#0160;behavior&#0160;is&#0160;not&#0160;JSON&#0160;specification&#0160;compliant,</span><br />
+<a class="lnum" href="#133" name="133">0133</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;but&#0160;is&#0160;consistent&#0160;with&#0160;most&#0160;JavaScript&#0160;based&#0160;encoders&#0160;and&#0160;decoders.</span><br />
+<a class="lnum" href="#134" name="134">0134</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;Otherwise,&#0160;it&#0160;will&#0160;be&#0160;a&#0160;ValueError&#0160;to&#0160;encode&#0160;such&#0160;floats.</span><br />
+<a class="lnum" href="#135" name="135">0135</a><span class="string"></span><br />
+<a class="lnum" href="#136" name="136">0136</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;If&#0160;sort_keys&#0160;is&#0160;True,&#0160;then&#0160;the&#0160;output&#0160;of&#0160;dictionaries&#0160;will&#0160;be</span><br />
+<a class="lnum" href="#137" name="137">0137</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;sorted&#0160;by&#0160;key;&#0160;this&#0160;is&#0160;useful&#0160;for&#0160;regression&#0160;tests&#0160;to&#0160;ensure</span><br />
+<a class="lnum" href="#138" name="138">0138</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;that&#0160;JSON&#0160;serializations&#0160;can&#0160;be&#0160;compared&#0160;on&#0160;a&#0160;day-to-day&#0160;basis.</span><br />
+<a class="lnum" href="#139" name="139">0139</a><span class="string"></span><br />
+<a class="lnum" href="#140" name="140">0140</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;If&#0160;indent&#0160;is&#0160;a&#0160;non-negative&#0160;integer,&#0160;then&#0160;JSON&#0160;array</span><br />
+<a class="lnum" href="#141" name="141">0141</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;elements&#0160;and&#0160;object&#0160;members&#0160;will&#0160;be&#0160;pretty-printed&#0160;with&#0160;that</span><br />
+<a class="lnum" href="#142" name="142">0142</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;indent&#0160;level.&#0160;&#0160;An&#0160;indent&#0160;level&#0160;of&#0160;0&#0160;will&#0160;only&#0160;insert&#0160;newlines.</span><br />
+<a class="lnum" href="#143" name="143">0143</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;None&#0160;is&#0160;the&#0160;most&#0160;compact&#0160;representation.</span><br />
+<a class="lnum" href="#144" name="144">0144</a><span class="string"></span><br />
+<a class="lnum" href="#145" name="145">0145</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;If&#0160;specified,&#0160;separators&#0160;should&#0160;be&#0160;a&#0160;(item_separator,&#0160;key_separator)</span><br />
+<a class="lnum" href="#146" name="146">0146</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;tuple.&#0160;The&#0160;default&#0160;is&#0160;(',&#0160;',&#0160;':&#0160;').&#0160;To&#0160;get&#0160;the&#0160;most&#0160;compact&#0160;JSON</span><br />
+<a class="lnum" href="#147" name="147">0147</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;representation&#0160;you&#0160;should&#0160;specify&#0160;(',',&#0160;':')&#0160;to&#0160;eliminate&#0160;whitespace.</span><br />
+<a class="lnum" href="#148" name="148">0148</a><span class="string"></span><br />
+<a class="lnum" href="#149" name="149">0149</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;If&#0160;encoding&#0160;is&#0160;not&#0160;None,&#0160;then&#0160;all&#0160;input&#0160;strings&#0160;will&#0160;be</span><br />
+<a class="lnum" href="#150" name="150">0150</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;transformed&#0160;into&#0160;unicode&#0160;using&#0160;that&#0160;encoding&#0160;prior&#0160;to&#0160;JSON-encoding.&#0160;</span><br />
+<a class="lnum" href="#151" name="151">0151</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;The&#0160;default&#0160;is&#0160;UTF-8.</span><br />
+<a class="lnum" href="#152" name="152">0152</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#153" name="153">0153</a><br />
+<a class="lnum" href="#154" name="154">0154</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">skipkeys</span>&#0160;<span class="op">=</span>&#0160;<span class="name">skipkeys</span><br />
+<a class="lnum" href="#155" name="155">0155</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">ensure_ascii</span>&#0160;<span class="op">=</span>&#0160;<span class="name">ensure_ascii</span><br />
+<a class="lnum" href="#156" name="156">0156</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">check_circular</span>&#0160;<span class="op">=</span>&#0160;<span class="name">check_circular</span><br />
+<a class="lnum" href="#157" name="157">0157</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">allow_nan</span>&#0160;<span class="op">=</span>&#0160;<span class="name">allow_nan</span><br />
+<a class="lnum" href="#158" name="158">0158</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">sort_keys</span>&#0160;<span class="op">=</span>&#0160;<span class="name">sort_keys</span><br />
+<a class="lnum" href="#159" name="159">0159</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">indent</span>&#0160;<span class="op">=</span>&#0160;<span class="name">indent</span><br />
+<a class="lnum" href="#160" name="160">0160</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">current_indent_level</span>&#0160;<span class="op">=</span>&#0160;<span class="number">0</span><br />
+<a class="lnum" href="#161" name="161">0161</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">separators</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#162" name="162">0162</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">item_separator</span><span class="op">,</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">key_separator</span>&#0160;<span class="op">=</span>&#0160;<span class="name">separators</span><br />
+<a class="lnum" href="#163" name="163">0163</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">encoding</span>&#0160;<span class="op">=</span>&#0160;<span class="name">encoding</span><br />
+<a class="lnum" href="#164" name="164">0164</a><br />
+<a class="lnum" href="#165" name="165">0165</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">_newline_indent</span><span class="op">(</span><span class="name">self</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#166" name="166">0166</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="string">'\n'</span>&#0160;<span class="op">+</span>&#0160;<span class="op">(</span><span class="string">'&#0160;'</span>&#0160;<span class="op">*</span>&#0160;<span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">indent</span>&#0160;<span class="op">*</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">current_indent_level</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#167" name="167">0167</a><br />
+<a class="lnum" href="#168" name="168">0168</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">_iterencode_list</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">lst</span><span class="op">,</span>&#0160;<span class="name">markers</span><span class="op">=</span><span class="name">None</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#169" name="169">0169</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">lst</span><span class="op">:</span><br />
+<a class="lnum" href="#170" name="170">0170</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="string">'[]'</span><br />
+<a class="lnum" href="#171" name="171">0171</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span><br />
+<a class="lnum" href="#172" name="172">0172</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">markers</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#173" name="173">0173</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">markerid</span>&#0160;<span class="op">=</span>&#0160;<span class="name">id</span><span class="op">(</span><span class="name">lst</span><span class="op">)</span><br />
+<a class="lnum" href="#174" name="174">0174</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">markerid</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">markers</span><span class="op">:</span><br />
+<a class="lnum" href="#175" name="175">0175</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><span class="string">"Circular&#0160;reference&#0160;detected"</span><span class="op">)</span><br />
+<a class="lnum" href="#176" name="176">0176</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">markers</span><span class="op">[</span><span class="name">markerid</span><span class="op">]</span>&#0160;<span class="op">=</span>&#0160;<span class="name">lst</span><br />
+<a class="lnum" href="#177" name="177">0177</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="string">'['</span><br />
+<a class="lnum" href="#178" name="178">0178</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">indent</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#179" name="179">0179</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">current_indent_level</span>&#0160;<span class="op">+=</span>&#0160;<span class="number">1</span><br />
+<a class="lnum" href="#180" name="180">0180</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">newline_indent</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">_newline_indent</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#181" name="181">0181</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">separator</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">item_separator</span>&#0160;<span class="op">+</span>&#0160;<span class="name">newline_indent</span><br />
+<a class="lnum" href="#182" name="182">0182</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">newline_indent</span><br />
+<a class="lnum" href="#183" name="183">0183</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#184" name="184">0184</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">newline_indent</span>&#0160;<span class="op">=</span>&#0160;<span class="name">None</span><br />
+<a class="lnum" href="#185" name="185">0185</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">separator</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">item_separator</span><br />
+<a class="lnum" href="#186" name="186">0186</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">first</span>&#0160;<span class="op">=</span>&#0160;<span class="name">True</span><br />
+<a class="lnum" href="#187" name="187">0187</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">for</span>&#0160;<span class="name">value</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">lst</span><span class="op">:</span><br />
+<a class="lnum" href="#188" name="188">0188</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">first</span><span class="op">:</span><br />
+<a class="lnum" href="#189" name="189">0189</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">first</span>&#0160;<span class="op">=</span>&#0160;<span class="name">False</span><br />
+<a class="lnum" href="#190" name="190">0190</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#191" name="191">0191</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">separator</span><br />
+<a class="lnum" href="#192" name="192">0192</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">for</span>&#0160;<span class="name">chunk</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">_iterencode</span><span class="op">(</span><span class="name">value</span><span class="op">,</span>&#0160;<span class="name">markers</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#193" name="193">0193</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">chunk</span><br />
+<a class="lnum" href="#194" name="194">0194</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">newline_indent</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#195" name="195">0195</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">current_indent_level</span>&#0160;<span class="op">-=</span>&#0160;<span class="number">1</span><br />
+<a class="lnum" href="#196" name="196">0196</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">_newline_indent</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#197" name="197">0197</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="string">']'</span><br />
+<a class="lnum" href="#198" name="198">0198</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">markers</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#199" name="199">0199</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">del</span>&#0160;<span class="name">markers</span><span class="op">[</span><span class="name">markerid</span><span class="op">]</span><br />
+<a class="lnum" href="#200" name="200">0200</a><br />
+<a class="lnum" href="#201" name="201">0201</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">_iterencode_dict</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">dct</span><span class="op">,</span>&#0160;<span class="name">markers</span><span class="op">=</span><span class="name">None</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#202" name="202">0202</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">dct</span><span class="op">:</span><br />
+<a class="lnum" href="#203" name="203">0203</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="string">'{}'</span><br />
+<a class="lnum" href="#204" name="204">0204</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span><br />
+<a class="lnum" href="#205" name="205">0205</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">markers</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#206" name="206">0206</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">markerid</span>&#0160;<span class="op">=</span>&#0160;<span class="name">id</span><span class="op">(</span><span class="name">dct</span><span class="op">)</span><br />
+<a class="lnum" href="#207" name="207">0207</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">markerid</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">markers</span><span class="op">:</span><br />
+<a class="lnum" href="#208" name="208">0208</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><span class="string">"Circular&#0160;reference&#0160;detected"</span><span class="op">)</span><br />
+<a class="lnum" href="#209" name="209">0209</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">markers</span><span class="op">[</span><span class="name">markerid</span><span class="op">]</span>&#0160;<span class="op">=</span>&#0160;<span class="name">dct</span><br />
+<a class="lnum" href="#210" name="210">0210</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="string">'{'</span><br />
+<a class="lnum" href="#211" name="211">0211</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">key_separator</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">key_separator</span><br />
+<a class="lnum" href="#212" name="212">0212</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">indent</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#213" name="213">0213</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">current_indent_level</span>&#0160;<span class="op">+=</span>&#0160;<span class="number">1</span><br />
+<a class="lnum" href="#214" name="214">0214</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">newline_indent</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">_newline_indent</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#215" name="215">0215</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">item_separator</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">item_separator</span>&#0160;<span class="op">+</span>&#0160;<span class="name">newline_indent</span><br />
+<a class="lnum" href="#216" name="216">0216</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">newline_indent</span><br />
+<a class="lnum" href="#217" name="217">0217</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#218" name="218">0218</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">newline_indent</span>&#0160;<span class="op">=</span>&#0160;<span class="name">None</span><br />
+<a class="lnum" href="#219" name="219">0219</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">item_separator</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">item_separator</span><br />
+<a class="lnum" href="#220" name="220">0220</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">first</span>&#0160;<span class="op">=</span>&#0160;<span class="name">True</span><br />
+<a class="lnum" href="#221" name="221">0221</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">ensure_ascii</span><span class="op">:</span><br />
+<a class="lnum" href="#222" name="222">0222</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">encoder</span>&#0160;<span class="op">=</span>&#0160;<span class="name">encode_basestring_ascii</span><br />
+<a class="lnum" href="#223" name="223">0223</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#224" name="224">0224</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">encoder</span>&#0160;<span class="op">=</span>&#0160;<span class="name">encode_basestring</span><br />
+<a class="lnum" href="#225" name="225">0225</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">allow_nan</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">allow_nan</span><br />
+<a class="lnum" href="#226" name="226">0226</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">sort_keys</span><span class="op">:</span><br />
+<a class="lnum" href="#227" name="227">0227</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">keys</span>&#0160;<span class="op">=</span>&#0160;<span class="name">dct</span><span class="op">.</span><span class="name">keys</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#228" name="228">0228</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">keys</span><span class="op">.</span><span class="name">sort</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#229" name="229">0229</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">items</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="op">(</span><span class="name">k</span><span class="op">,</span>&#0160;<span class="name">dct</span><span class="op">[</span><span class="name">k</span><span class="op">]</span><span class="op">)</span>&#0160;<span class="keyword">for</span>&#0160;<span class="name">k</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">keys</span><span class="op">]</span><br />
+<a class="lnum" href="#230" name="230">0230</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#231" name="231">0231</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">items</span>&#0160;<span class="op">=</span>&#0160;<span class="name">dct</span><span class="op">.</span><span class="name">iteritems</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#232" name="232">0232</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">_encoding</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">encoding</span><br />
+<a class="lnum" href="#233" name="233">0233</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">_do_decode</span>&#0160;<span class="op">=</span>&#0160;<span class="op">(</span><span class="name">_encoding</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><br />
+<a class="lnum" href="#234" name="234">0234</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">and</span>&#0160;<span class="keyword">not</span>&#0160;<span class="op">(</span><span class="name">_need_utf8</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">_encoding</span>&#0160;<span class="op">==</span>&#0160;<span class="string">'utf-8'</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#235" name="235">0235</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">for</span>&#0160;<span class="name">key</span><span class="op">,</span>&#0160;<span class="name">value</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">items</span><span class="op">:</span><br />
+<a class="lnum" href="#236" name="236">0236</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">isinstance</span><span class="op">(</span><span class="name">key</span><span class="op">,</span>&#0160;<span class="name">str</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#237" name="237">0237</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">_do_decode</span><span class="op">:</span><br />
+<a class="lnum" href="#238" name="238">0238</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">key</span>&#0160;<span class="op">=</span>&#0160;<span class="name">key</span><span class="op">.</span><span class="name">decode</span><span class="op">(</span><span class="name">_encoding</span><span class="op">)</span><br />
+<a class="lnum" href="#239" name="239">0239</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">isinstance</span><span class="op">(</span><span class="name">key</span><span class="op">,</span>&#0160;<span class="name">basestring</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#240" name="240">0240</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">pass</span><br />
+<a class="lnum" href="#241" name="241">0241</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;JavaScript&#0160;is&#0160;weakly&#0160;typed&#0160;for&#0160;these,&#0160;so&#0160;it&#0160;makes&#0160;sense&#0160;to</span><br />
+<a class="lnum" href="#242" name="242">0242</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;also&#0160;allow&#0160;them.&#0160;&#0160;Many&#0160;encoders&#0160;seem&#0160;to&#0160;do&#0160;something&#0160;like&#0160;this.</span><br />
+<a class="lnum" href="#243" name="243">0243</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">isinstance</span><span class="op">(</span><span class="name">key</span><span class="op">,</span>&#0160;<span class="name">float</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#244" name="244">0244</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">key</span>&#0160;<span class="op">=</span>&#0160;<span class="name">floatstr</span><span class="op">(</span><span class="name">key</span><span class="op">,</span>&#0160;<span class="name">allow_nan</span><span class="op">)</span><br />
+<a class="lnum" href="#245" name="245">0245</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">isinstance</span><span class="op">(</span><span class="name">key</span><span class="op">,</span>&#0160;<span class="op">(</span><span class="name">int</span><span class="op">,</span>&#0160;<span class="name">long</span><span class="op">)</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#246" name="246">0246</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">key</span>&#0160;<span class="op">=</span>&#0160;<span class="name">str</span><span class="op">(</span><span class="name">key</span><span class="op">)</span><br />
+<a class="lnum" href="#247" name="247">0247</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">key</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">True</span><span class="op">:</span><br />
+<a class="lnum" href="#248" name="248">0248</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">key</span>&#0160;<span class="op">=</span>&#0160;<span class="string">'true'</span><br />
+<a class="lnum" href="#249" name="249">0249</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">key</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">False</span><span class="op">:</span><br />
+<a class="lnum" href="#250" name="250">0250</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">key</span>&#0160;<span class="op">=</span>&#0160;<span class="string">'false'</span><br />
+<a class="lnum" href="#251" name="251">0251</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">key</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#252" name="252">0252</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">key</span>&#0160;<span class="op">=</span>&#0160;<span class="string">'null'</span><br />
+<a class="lnum" href="#253" name="253">0253</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">skipkeys</span><span class="op">:</span><br />
+<a class="lnum" href="#254" name="254">0254</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">continue</span><br />
+<a class="lnum" href="#255" name="255">0255</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#256" name="256">0256</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">TypeError</span><span class="op">(</span><span class="string">"key&#0160;%r&#0160;is&#0160;not&#0160;a&#0160;string"</span>&#0160;<span class="op">%</span>&#0160;<span class="op">(</span><span class="name">key</span><span class="op">,</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#257" name="257">0257</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">first</span><span class="op">:</span><br />
+<a class="lnum" href="#258" name="258">0258</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">first</span>&#0160;<span class="op">=</span>&#0160;<span class="name">False</span><br />
+<a class="lnum" href="#259" name="259">0259</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#260" name="260">0260</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">item_separator</span><br />
+<a class="lnum" href="#261" name="261">0261</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">encoder</span><span class="op">(</span><span class="name">key</span><span class="op">)</span><br />
+<a class="lnum" href="#262" name="262">0262</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">key_separator</span><br />
+<a class="lnum" href="#263" name="263">0263</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">for</span>&#0160;<span class="name">chunk</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">_iterencode</span><span class="op">(</span><span class="name">value</span><span class="op">,</span>&#0160;<span class="name">markers</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#264" name="264">0264</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">chunk</span><br />
+<a class="lnum" href="#265" name="265">0265</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">newline_indent</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#266" name="266">0266</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">current_indent_level</span>&#0160;<span class="op">-=</span>&#0160;<span class="number">1</span><br />
+<a class="lnum" href="#267" name="267">0267</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">_newline_indent</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#268" name="268">0268</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="string">'}'</span><br />
+<a class="lnum" href="#269" name="269">0269</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">markers</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#270" name="270">0270</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">del</span>&#0160;<span class="name">markers</span><span class="op">[</span><span class="name">markerid</span><span class="op">]</span><br />
+<a class="lnum" href="#271" name="271">0271</a><br />
+<a class="lnum" href="#272" name="272">0272</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">_iterencode</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">o</span><span class="op">,</span>&#0160;<span class="name">markers</span><span class="op">=</span><span class="name">None</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#273" name="273">0273</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">isinstance</span><span class="op">(</span><span class="name">o</span><span class="op">,</span>&#0160;<span class="name">basestring</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#274" name="274">0274</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">ensure_ascii</span><span class="op">:</span><br />
+<a class="lnum" href="#275" name="275">0275</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">encoder</span>&#0160;<span class="op">=</span>&#0160;<span class="name">encode_basestring_ascii</span><br />
+<a class="lnum" href="#276" name="276">0276</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#277" name="277">0277</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">encoder</span>&#0160;<span class="op">=</span>&#0160;<span class="name">encode_basestring</span><br />
+<a class="lnum" href="#278" name="278">0278</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">_encoding</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">encoding</span><br />
+<a class="lnum" href="#279" name="279">0279</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="op">(</span><span class="name">_encoding</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">isinstance</span><span class="op">(</span><span class="name">o</span><span class="op">,</span>&#0160;<span class="name">str</span><span class="op">)</span><br />
+<a class="lnum" href="#280" name="280">0280</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">and</span>&#0160;<span class="keyword">not</span>&#0160;<span class="op">(</span><span class="name">_need_utf8</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">_encoding</span>&#0160;<span class="op">==</span>&#0160;<span class="string">'utf-8'</span><span class="op">)</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#281" name="281">0281</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">o</span>&#0160;<span class="op">=</span>&#0160;<span class="name">o</span><span class="op">.</span><span class="name">decode</span><span class="op">(</span><span class="name">_encoding</span><span class="op">)</span><br />
+<a class="lnum" href="#282" name="282">0282</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">encoder</span><span class="op">(</span><span class="name">o</span><span class="op">)</span><br />
+<a class="lnum" href="#283" name="283">0283</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">o</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#284" name="284">0284</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="string">'null'</span><br />
+<a class="lnum" href="#285" name="285">0285</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">o</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">True</span><span class="op">:</span><br />
+<a class="lnum" href="#286" name="286">0286</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="string">'true'</span><br />
+<a class="lnum" href="#287" name="287">0287</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">o</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">False</span><span class="op">:</span><br />
+<a class="lnum" href="#288" name="288">0288</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="string">'false'</span><br />
+<a class="lnum" href="#289" name="289">0289</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">isinstance</span><span class="op">(</span><span class="name">o</span><span class="op">,</span>&#0160;<span class="op">(</span><span class="name">int</span><span class="op">,</span>&#0160;<span class="name">long</span><span class="op">)</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#290" name="290">0290</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">str</span><span class="op">(</span><span class="name">o</span><span class="op">)</span><br />
+<a class="lnum" href="#291" name="291">0291</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">isinstance</span><span class="op">(</span><span class="name">o</span><span class="op">,</span>&#0160;<span class="name">float</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#292" name="292">0292</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">floatstr</span><span class="op">(</span><span class="name">o</span><span class="op">,</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">allow_nan</span><span class="op">)</span><br />
+<a class="lnum" href="#293" name="293">0293</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">isinstance</span><span class="op">(</span><span class="name">o</span><span class="op">,</span>&#0160;<span class="op">(</span><span class="name">list</span><span class="op">,</span>&#0160;<span class="name">tuple</span><span class="op">)</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#294" name="294">0294</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">for</span>&#0160;<span class="name">chunk</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">_iterencode_list</span><span class="op">(</span><span class="name">o</span><span class="op">,</span>&#0160;<span class="name">markers</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#295" name="295">0295</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">chunk</span><br />
+<a class="lnum" href="#296" name="296">0296</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">isinstance</span><span class="op">(</span><span class="name">o</span><span class="op">,</span>&#0160;<span class="name">dict</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#297" name="297">0297</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">for</span>&#0160;<span class="name">chunk</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">_iterencode_dict</span><span class="op">(</span><span class="name">o</span><span class="op">,</span>&#0160;<span class="name">markers</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#298" name="298">0298</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">chunk</span><br />
+<a class="lnum" href="#299" name="299">0299</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#300" name="300">0300</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">markers</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#301" name="301">0301</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">markerid</span>&#0160;<span class="op">=</span>&#0160;<span class="name">id</span><span class="op">(</span><span class="name">o</span><span class="op">)</span><br />
+<a class="lnum" href="#302" name="302">0302</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">markerid</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">markers</span><span class="op">:</span><br />
+<a class="lnum" href="#303" name="303">0303</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ValueError</span><span class="op">(</span><span class="string">"Circular&#0160;reference&#0160;detected"</span><span class="op">)</span><br />
+<a class="lnum" href="#304" name="304">0304</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">markers</span><span class="op">[</span><span class="name">markerid</span><span class="op">]</span>&#0160;<span class="op">=</span>&#0160;<span class="name">o</span><br />
+<a class="lnum" href="#305" name="305">0305</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">for</span>&#0160;<span class="name">chunk</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">_iterencode_default</span><span class="op">(</span><span class="name">o</span><span class="op">,</span>&#0160;<span class="name">markers</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#306" name="306">0306</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">chunk</span><br />
+<a class="lnum" href="#307" name="307">0307</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">markers</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#308" name="308">0308</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">del</span>&#0160;<span class="name">markers</span><span class="op">[</span><span class="name">markerid</span><span class="op">]</span><br />
+<a class="lnum" href="#309" name="309">0309</a><br />
+<a class="lnum" href="#310" name="310">0310</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">_iterencode_default</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">o</span><span class="op">,</span>&#0160;<span class="name">markers</span><span class="op">=</span><span class="name">None</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#311" name="311">0311</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">newobj</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">default</span><span class="op">(</span><span class="name">o</span><span class="op">)</span><br />
+<a class="lnum" href="#312" name="312">0312</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">_iterencode</span><span class="op">(</span><span class="name">newobj</span><span class="op">,</span>&#0160;<span class="name">markers</span><span class="op">)</span><br />
+<a class="lnum" href="#313" name="313">0313</a><br />
+<a class="lnum" href="#314" name="314">0314</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">default</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">o</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#315" name="315">0315</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#316" name="316">0316</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;Implement&#0160;this&#0160;method&#0160;in&#0160;a&#0160;subclass&#0160;such&#0160;that&#0160;it&#0160;returns</span><br />
+<a class="lnum" href="#317" name="317">0317</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;a&#0160;serializable&#0160;object&#0160;for&#0160;``o``,&#0160;or&#0160;calls&#0160;the&#0160;base&#0160;implementation</span><br />
+<a class="lnum" href="#318" name="318">0318</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;(to&#0160;raise&#0160;a&#0160;``TypeError``).</span><br />
+<a class="lnum" href="#319" name="319">0319</a><span class="string"></span><br />
+<a class="lnum" href="#320" name="320">0320</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;For&#0160;example,&#0160;to&#0160;support&#0160;arbitrary&#0160;iterators,&#0160;you&#0160;could</span><br />
+<a class="lnum" href="#321" name="321">0321</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;implement&#0160;default&#0160;like&#0160;this::</span><br />
+<a class="lnum" href="#322" name="322">0322</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;</span><br />
+<a class="lnum" href="#323" name="323">0323</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;def&#0160;default(self,&#0160;o):</span><br />
+<a class="lnum" href="#324" name="324">0324</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;try:</span><br />
+<a class="lnum" href="#325" name="325">0325</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;iterable&#0160;=&#0160;iter(o)</span><br />
+<a class="lnum" href="#326" name="326">0326</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;except&#0160;TypeError:</span><br />
+<a class="lnum" href="#327" name="327">0327</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;pass</span><br />
+<a class="lnum" href="#328" name="328">0328</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;else:</span><br />
+<a class="lnum" href="#329" name="329">0329</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;return&#0160;list(iterable)</span><br />
+<a class="lnum" href="#330" name="330">0330</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;return&#0160;JSONEncoder.default(self,&#0160;o)</span><br />
+<a class="lnum" href="#331" name="331">0331</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#332" name="332">0332</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">TypeError</span><span class="op">(</span><span class="string">"%r&#0160;is&#0160;not&#0160;JSON&#0160;serializable"</span>&#0160;<span class="op">%</span>&#0160;<span class="op">(</span><span class="name">o</span><span class="op">,</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#333" name="333">0333</a><br />
+<a class="lnum" href="#334" name="334">0334</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">encode</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">o</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#335" name="335">0335</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#336" name="336">0336</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;Return&#0160;a&#0160;JSON&#0160;string&#0160;representation&#0160;of&#0160;a&#0160;Python&#0160;data&#0160;structure.</span><br />
+<a class="lnum" href="#337" name="337">0337</a><span class="string"></span><br />
+<a class="lnum" href="#338" name="338">0338</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&gt;&gt;&gt;&#0160;JSONEncoder().encode({"foo":&#0160;["bar",&#0160;"baz"]})</span><br />
+<a class="lnum" href="#339" name="339">0339</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;'{"foo":["bar",&#0160;"baz"]}'</span><br />
+<a class="lnum" href="#340" name="340">0340</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#341" name="341">0341</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;This&#0160;is&#0160;for&#0160;extremely&#0160;simple&#0160;cases&#0160;and&#0160;benchmarks...</span><br />
+<a class="lnum" href="#342" name="342">0342</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">isinstance</span><span class="op">(</span><span class="name">o</span><span class="op">,</span>&#0160;<span class="name">basestring</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#343" name="343">0343</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">isinstance</span><span class="op">(</span><span class="name">o</span><span class="op">,</span>&#0160;<span class="name">str</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#344" name="344">0344</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">_encoding</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">encoding</span><br />
+<a class="lnum" href="#345" name="345">0345</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="op">(</span><span class="name">_encoding</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><br />
+<a class="lnum" href="#346" name="346">0346</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">and</span>&#0160;<span class="keyword">not</span>&#0160;<span class="op">(</span><span class="name">_encoding</span>&#0160;<span class="op">==</span>&#0160;<span class="string">'utf-8'</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">_need_utf8</span><span class="op">)</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#347" name="347">0347</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">o</span>&#0160;<span class="op">=</span>&#0160;<span class="name">o</span><span class="op">.</span><span class="name">decode</span><span class="op">(</span><span class="name">_encoding</span><span class="op">)</span><br />
+<a class="lnum" href="#348" name="348">0348</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">encode_basestring_ascii</span><span class="op">(</span><span class="name">o</span><span class="op">)</span><br />
+<a class="lnum" href="#349" name="349">0349</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;This&#0160;doesn't&#0160;pass&#0160;the&#0160;iterator&#0160;directly&#0160;to&#0160;''.join()&#0160;because&#0160;it</span><br />
+<a class="lnum" href="#350" name="350">0350</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;sucks&#0160;at&#0160;reporting&#0160;exceptions.&#0160;&#0160;It's&#0160;going&#0160;to&#0160;do&#0160;this&#0160;internally</span><br />
+<a class="lnum" href="#351" name="351">0351</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;anyway&#0160;because&#0160;it&#0160;uses&#0160;PySequence_Fast&#0160;or&#0160;similar.</span><br />
+<a class="lnum" href="#352" name="352">0352</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">chunks</span>&#0160;<span class="op">=</span>&#0160;<span class="name">list</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">iterencode</span><span class="op">(</span><span class="name">o</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#353" name="353">0353</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="string">''</span><span class="op">.</span><span class="name">join</span><span class="op">(</span><span class="name">chunks</span><span class="op">)</span><br />
+<a class="lnum" href="#354" name="354">0354</a><br />
+<a class="lnum" href="#355" name="355">0355</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">iterencode</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">o</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#356" name="356">0356</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#357" name="357">0357</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;Encode&#0160;the&#0160;given&#0160;object&#0160;and&#0160;yield&#0160;each&#0160;string</span><br />
+<a class="lnum" href="#358" name="358">0358</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;representation&#0160;as&#0160;available.</span><br />
+<a class="lnum" href="#359" name="359">0359</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;</span><br />
+<a class="lnum" href="#360" name="360">0360</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;For&#0160;example::</span><br />
+<a class="lnum" href="#361" name="361">0361</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;</span><br />
+<a class="lnum" href="#362" name="362">0362</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;for&#0160;chunk&#0160;in&#0160;JSONEncoder().iterencode(bigobject):</span><br />
+<a class="lnum" href="#363" name="363">0363</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;mysocket.write(chunk)</span><br />
+<a class="lnum" href="#364" name="364">0364</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#365" name="365">0365</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">check_circular</span><span class="op">:</span><br />
+<a class="lnum" href="#366" name="366">0366</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">markers</span>&#0160;<span class="op">=</span>&#0160;<span class="op">{</span><span class="op">}</span><br />
+<a class="lnum" href="#367" name="367">0367</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#368" name="368">0368</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">markers</span>&#0160;<span class="op">=</span>&#0160;<span class="name">None</span><br />
+<a class="lnum" href="#369" name="369">0369</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">_iterencode</span><span class="op">(</span><span class="name">o</span><span class="op">,</span>&#0160;<span class="name">markers</span><span class="op">)</span><br />
+<a class="lnum" href="#370" name="370">0370</a><br />
+<a class="lnum" href="#371" name="371">0371</a><span class="name">__all__</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="string">'JSONEncoder'</span><span class="op">]</span></code></div></body></html>
\ No newline at end of file
diff --git a/src/simplejson/docs/simplejson/jsonfilter.py.html b/src/simplejson/docs/simplejson/jsonfilter.py.html
new file mode 100644 (file)
index 0000000..874290b
--- /dev/null
@@ -0,0 +1,112 @@
+<html><head><title>/Users/bob/src/simplejson/simplejson/jsonfilter.py</title>
+        <script type="text/javascript"><!--
+        
+function show_line_range() {
+    var href = document.location.href;
+    if (href.indexOf('?') == -1) {
+        return;
+    }
+    var qs = href.substring(href.indexOf('?')+1);
+    if (qs.indexOf('#') >= 0) {
+        qs = qs.substring(0, qs.indexOf('#'));
+    }
+    var first = qs.match(/f=(\d+)/)[1];
+    var last = qs.match(/l=(\d+)/)[1];
+    if (! first || ! last) {
+        return;
+    }
+    var anchors = document.getElementsByTagName('A');
+    var container = document.createElement('DIV');
+    container.className = 'highlighted';
+    var children = [];
+    var start = null;
+    var parent = null;
+    var highlight = false;
+    for (var i = 0; i < anchors.length; i++) {
+        var el = anchors[i];
+        if (el.getAttribute('name') == first) {
+            start = el.previousSibling;
+            parent = el.parentNode;
+            highlight = true;
+        }
+        if (el.getAttribute('name') == last) {
+            break;
+        }
+        if (highlight) {
+            children[children.length] = el;
+            el = el.nextSibling;
+            while (el && el.tagName != 'A') {
+                children[children.length] = el;
+                el = el.nextSibling;
+            }
+        }
+    }
+    for (i=0; i<children.length; i++) {
+        container.appendChild(children[i]);
+    }
+    if (start) {
+        start.parentNode.insertBefore(container, start.nextSibling);
+    } else {
+        parent.insertBefore(container, parent.childNodes[0]);
+    }
+}
+
+        // --></script>
+        <style>
+        div.python {
+          color: #333
+        }
+        div.python a.lnum {
+          color: #555;
+          background-color: #eee;
+          border-right: 1px solid #999;
+          padding-right: 2px;
+          margin-right: 4px;
+        }
+        div.python span.comment { color: #933 }
+        div.python span.keyword { color: #a3e; font-weight: bold  }
+        div.python span.op { color: #c96 }
+        div.python span.string { color: #6a6 }
+        div.python span.name { }
+        div.python span.text { color: #333 }
+        div.highlighted { background-color: #ff9; border: 1px solid #009 }
+        </style></head><body onload="show_line_range()"><div class="python"><code><a class="lnum" href="#1" name="1">0001</a><span class="keyword">import</span>&#0160;<span class="name">simplejson</span><br />
+<a class="lnum" href="#2" name="2">0002</a><span class="keyword">import</span>&#0160;<span class="name">cgi</span><br />
+<a class="lnum" href="#3" name="3">0003</a><br />
+<a class="lnum" href="#4" name="4">0004</a><span class="keyword">class</span>&#0160;<span class="name">JSONFilter</span><span class="op">(</span><span class="name">object</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#5" name="5">0005</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__init__</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">app</span><span class="op">,</span>&#0160;<span class="name">mime_type</span><span class="op">=</span><span class="string">'text/x-json'</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#6" name="6">0006</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">app</span>&#0160;<span class="op">=</span>&#0160;<span class="name">app</span><br />
+<a class="lnum" href="#7" name="7">0007</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">mime_type</span>&#0160;<span class="op">=</span>&#0160;<span class="name">mime_type</span><br />
+<a class="lnum" href="#8" name="8">0008</a><br />
+<a class="lnum" href="#9" name="9">0009</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__call__</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">environ</span><span class="op">,</span>&#0160;<span class="name">start_response</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#10" name="10">0010</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;Read&#0160;JSON&#0160;POST&#0160;input&#0160;to&#0160;jsonfilter.json&#0160;if&#0160;matching&#0160;mime&#0160;type</span><br />
+<a class="lnum" href="#11" name="11">0011</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">response</span>&#0160;<span class="op">=</span>&#0160;<span class="op">{</span><span class="string">'status'</span><span class="op">:</span>&#0160;<span class="string">'200&#0160;OK'</span><span class="op">,</span>&#0160;<span class="string">'headers'</span><span class="op">:</span>&#0160;<span class="op">[</span><span class="op">]</span><span class="op">}</span><br />
+<a class="lnum" href="#12" name="12">0012</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">json_start_response</span><span class="op">(</span><span class="name">status</span><span class="op">,</span>&#0160;<span class="name">headers</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#13" name="13">0013</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">response</span><span class="op">[</span><span class="string">'status'</span><span class="op">]</span>&#0160;<span class="op">=</span>&#0160;<span class="name">status</span><br />
+<a class="lnum" href="#14" name="14">0014</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">response</span><span class="op">[</span><span class="string">'headers'</span><span class="op">]</span><span class="op">.</span><span class="name">extend</span><span class="op">(</span><span class="name">headers</span><span class="op">)</span><br />
+<a class="lnum" href="#15" name="15">0015</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">environ</span><span class="op">[</span><span class="string">'jsonfilter.mime_type'</span><span class="op">]</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">mime_type</span><br />
+<a class="lnum" href="#16" name="16">0016</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">environ</span><span class="op">.</span><span class="name">get</span><span class="op">(</span><span class="string">'REQUEST_METHOD'</span><span class="op">,</span>&#0160;<span class="string">''</span><span class="op">)</span>&#0160;<span class="op">==</span>&#0160;<span class="string">'POST'</span><span class="op">:</span><br />
+<a class="lnum" href="#17" name="17">0017</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">environ</span><span class="op">.</span><span class="name">get</span><span class="op">(</span><span class="string">'CONTENT_TYPE'</span><span class="op">,</span>&#0160;<span class="string">''</span><span class="op">)</span>&#0160;<span class="op">==</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">mime_type</span><span class="op">:</span><br />
+<a class="lnum" href="#18" name="18">0018</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">args</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="name">_</span>&#0160;<span class="keyword">for</span>&#0160;<span class="name">_</span>&#0160;<span class="keyword">in</span>&#0160;<span class="op">[</span><span class="name">environ</span><span class="op">.</span><span class="name">get</span><span class="op">(</span><span class="string">'CONTENT_LENGTH'</span><span class="op">)</span><span class="op">]</span>&#0160;<span class="keyword">if</span>&#0160;<span class="name">_</span><span class="op">]</span><br />
+<a class="lnum" href="#19" name="19">0019</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">data</span>&#0160;<span class="op">=</span>&#0160;<span class="name">environ</span><span class="op">[</span><span class="string">'wsgi.input'</span><span class="op">]</span><span class="op">.</span><span class="name">read</span><span class="op">(</span><span class="op">*</span><span class="name">map</span><span class="op">(</span><span class="name">int</span><span class="op">,</span>&#0160;<span class="name">args</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#20" name="20">0020</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">environ</span><span class="op">[</span><span class="string">'jsonfilter.json'</span><span class="op">]</span>&#0160;<span class="op">=</span>&#0160;<span class="name">simplejson</span><span class="op">.</span><span class="name">loads</span><span class="op">(</span><span class="name">data</span><span class="op">)</span><br />
+<a class="lnum" href="#21" name="21">0021</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">res</span>&#0160;<span class="op">=</span>&#0160;<span class="name">simplejson</span><span class="op">.</span><span class="name">dumps</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">app</span><span class="op">(</span><span class="name">environ</span><span class="op">,</span>&#0160;<span class="name">json_start_response</span><span class="op">)</span><span class="op">)</span><br />
+<a class="lnum" href="#22" name="22">0022</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">jsonp</span>&#0160;<span class="op">=</span>&#0160;<span class="name">cgi</span><span class="op">.</span><span class="name">parse_qs</span><span class="op">(</span><span class="name">environ</span><span class="op">.</span><span class="name">get</span><span class="op">(</span><span class="string">'QUERY_STRING'</span><span class="op">,</span>&#0160;<span class="string">''</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="name">get</span><span class="op">(</span><span class="string">'jsonp'</span><span class="op">)</span><br />
+<a class="lnum" href="#23" name="23">0023</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">jsonp</span><span class="op">:</span><br />
+<a class="lnum" href="#24" name="24">0024</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">content_type</span>&#0160;<span class="op">=</span>&#0160;<span class="string">'text/javascript'</span><br />
+<a class="lnum" href="#25" name="25">0025</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">res</span>&#0160;<span class="op">=</span>&#0160;<span class="string">''</span><span class="op">.</span><span class="name">join</span><span class="op">(</span><span class="name">jsonp</span>&#0160;<span class="op">+</span>&#0160;<span class="op">[</span><span class="string">'('</span><span class="op">,</span>&#0160;<span class="name">res</span><span class="op">,</span>&#0160;<span class="string">')'</span><span class="op">]</span><span class="op">)</span><br />
+<a class="lnum" href="#26" name="26">0026</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="string">'Opera'</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">environ</span><span class="op">.</span><span class="name">get</span><span class="op">(</span><span class="string">'HTTP_USER_AGENT'</span><span class="op">,</span>&#0160;<span class="string">''</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#27" name="27">0027</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;Opera&#0160;has&#0160;bunk&#0160;XMLHttpRequest&#0160;support&#0160;for&#0160;most&#0160;mime&#0160;types</span><br />
+<a class="lnum" href="#28" name="28">0028</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">content_type</span>&#0160;<span class="op">=</span>&#0160;<span class="string">'text/plain'</span><br />
+<a class="lnum" href="#29" name="29">0029</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
+<a class="lnum" href="#30" name="30">0030</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">content_type</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">mime_type</span><br />
+<a class="lnum" href="#31" name="31">0031</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">headers</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><br />
+<a class="lnum" href="#32" name="32">0032</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="op">(</span><span class="string">'Content-type'</span><span class="op">,</span>&#0160;<span class="name">content_type</span><span class="op">)</span><span class="op">,</span><br />
+<a class="lnum" href="#33" name="33">0033</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="op">(</span><span class="string">'Content-length'</span><span class="op">,</span>&#0160;<span class="name">len</span><span class="op">(</span><span class="name">res</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><br />
+<a class="lnum" href="#34" name="34">0034</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="op">]</span><br />
+<a class="lnum" href="#35" name="35">0035</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">headers</span><span class="op">.</span><span class="name">extend</span><span class="op">(</span><span class="name">response</span><span class="op">[</span><span class="string">'headers'</span><span class="op">]</span><span class="op">)</span><br />
+<a class="lnum" href="#36" name="36">0036</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">start_response</span><span class="op">(</span><span class="name">response</span><span class="op">[</span><span class="string">'status'</span><span class="op">]</span><span class="op">,</span>&#0160;<span class="name">headers</span><span class="op">)</span><br />
+<a class="lnum" href="#37" name="37">0037</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="op">[</span><span class="name">res</span><span class="op">]</span><br />
+<a class="lnum" href="#38" name="38">0038</a><br />
+<a class="lnum" href="#39" name="39">0039</a><span class="keyword">def</span>&#0160;<span class="name">factory</span><span class="op">(</span><span class="name">app</span><span class="op">,</span>&#0160;<span class="name">global_conf</span><span class="op">,</span>&#0160;<span class="op">**</span><span class="name">kw</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#40" name="40">0040</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">JSONFilter</span><span class="op">(</span><span class="name">app</span><span class="op">,</span>&#0160;<span class="op">**</span><span class="name">kw</span><span class="op">)</span></code></div></body></html>
\ No newline at end of file
diff --git a/src/simplejson/docs/simplejson/scanner.py.html b/src/simplejson/docs/simplejson/scanner.py.html
new file mode 100644 (file)
index 0000000..031da08
--- /dev/null
@@ -0,0 +1,135 @@
+<html><head><title>/Users/bob/src/simplejson/simplejson/scanner.py</title>
+        <script type="text/javascript"><!--
+        
+function show_line_range() {
+    var href = document.location.href;
+    if (href.indexOf('?') == -1) {
+        return;
+    }
+    var qs = href.substring(href.indexOf('?')+1);
+    if (qs.indexOf('#') >= 0) {
+        qs = qs.substring(0, qs.indexOf('#'));
+    }
+    var first = qs.match(/f=(\d+)/)[1];
+    var last = qs.match(/l=(\d+)/)[1];
+    if (! first || ! last) {
+        return;
+    }
+    var anchors = document.getElementsByTagName('A');
+    var container = document.createElement('DIV');
+    container.className = 'highlighted';
+    var children = [];
+    var start = null;
+    var parent = null;
+    var highlight = false;
+    for (var i = 0; i < anchors.length; i++) {
+        var el = anchors[i];
+        if (el.getAttribute('name') == first) {
+            start = el.previousSibling;
+            parent = el.parentNode;
+            highlight = true;
+        }
+        if (el.getAttribute('name') == last) {
+            break;
+        }
+        if (highlight) {
+            children[children.length] = el;
+            el = el.nextSibling;
+            while (el && el.tagName != 'A') {
+                children[children.length] = el;
+                el = el.nextSibling;
+            }
+        }
+    }
+    for (i=0; i<children.length; i++) {
+        container.appendChild(children[i]);
+    }
+    if (start) {
+        start.parentNode.insertBefore(container, start.nextSibling);
+    } else {
+        parent.insertBefore(container, parent.childNodes[0]);
+    }
+}
+
+        // --></script>
+        <style>
+        div.python {
+          color: #333
+        }
+        div.python a.lnum {
+          color: #555;
+          background-color: #eee;
+          border-right: 1px solid #999;
+          padding-right: 2px;
+          margin-right: 4px;
+        }
+        div.python span.comment { color: #933 }
+        div.python span.keyword { color: #a3e; font-weight: bold  }
+        div.python span.op { color: #c96 }
+        div.python span.string { color: #6a6 }
+        div.python span.name { }
+        div.python span.text { color: #333 }
+        div.highlighted { background-color: #ff9; border: 1px solid #009 }
+        </style></head><body onload="show_line_range()"><div class="python"><code><a class="lnum" href="#1" name="1">0001</a><span class="string">"""</span><br />
+<a class="lnum" href="#2" name="2">0002</a><span class="string">Iterator&#0160;based&#0160;sre&#0160;token&#0160;scanner</span><br />
+<a class="lnum" href="#3" name="3">0003</a><span class="string">"""</span><br />
+<a class="lnum" href="#4" name="4">0004</a><span class="keyword">import</span>&#0160;<span class="name">sre_parse</span><span class="op">,</span>&#0160;<span class="name">sre_compile</span><span class="op">,</span>&#0160;<span class="name">sre_constants</span><br />
+<a class="lnum" href="#5" name="5">0005</a><span class="keyword">from</span>&#0160;<span class="name">sre_constants</span>&#0160;<span class="keyword">import</span>&#0160;<span class="name">BRANCH</span><span class="op">,</span>&#0160;<span class="name">SUBPATTERN</span><br />
+<a class="lnum" href="#6" name="6">0006</a><span class="keyword">from</span>&#0160;<span class="name">re</span>&#0160;<span class="keyword">import</span>&#0160;<span class="name">VERBOSE</span><span class="op">,</span>&#0160;<span class="name">MULTILINE</span><span class="op">,</span>&#0160;<span class="name">DOTALL</span><br />
+<a class="lnum" href="#7" name="7">0007</a><span class="keyword">import</span>&#0160;<span class="name">re</span><br />
+<a class="lnum" href="#8" name="8">0008</a><br />
+<a class="lnum" href="#9" name="9">0009</a><span class="name">__all__</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="string">'Scanner'</span><span class="op">,</span>&#0160;<span class="string">'pattern'</span><span class="op">]</span><br />
+<a class="lnum" href="#10" name="10">0010</a><br />
+<a class="lnum" href="#11" name="11">0011</a><span class="name">FLAGS</span>&#0160;<span class="op">=</span>&#0160;<span class="op">(</span><span class="name">VERBOSE</span>&#0160;<span class="op">|</span>&#0160;<span class="name">MULTILINE</span>&#0160;<span class="op">|</span>&#0160;<span class="name">DOTALL</span><span class="op">)</span><br />
+<a class="lnum" href="#12" name="12">0012</a><span class="keyword">class</span>&#0160;<span class="name">Scanner</span><span class="op">(</span><span class="name">object</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#13" name="13">0013</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__init__</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">lexicon</span><span class="op">,</span>&#0160;<span class="name">flags</span><span class="op">=</span><span class="name">FLAGS</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#14" name="14">0014</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">actions</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="name">None</span><span class="op">]</span><br />
+<a class="lnum" href="#15" name="15">0015</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;combine&#0160;phrases&#0160;into&#0160;a&#0160;compound&#0160;pattern</span><br />
+<a class="lnum" href="#16" name="16">0016</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">s</span>&#0160;<span class="op">=</span>&#0160;<span class="name">sre_parse</span><span class="op">.</span><span class="name">Pattern</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#17" name="17">0017</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">s</span><span class="op">.</span><span class="name">flags</span>&#0160;<span class="op">=</span>&#0160;<span class="name">flags</span><br />
+<a class="lnum" href="#18" name="18">0018</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">p</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="op">]</span><br />
+<a class="lnum" href="#19" name="19">0019</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">for</span>&#0160;<span class="name">idx</span><span class="op">,</span>&#0160;<span class="name">token</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">enumerate</span><span class="op">(</span><span class="name">lexicon</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#20" name="20">0020</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">phrase</span>&#0160;<span class="op">=</span>&#0160;<span class="name">token</span><span class="op">.</span><span class="name">pattern</span><br />
+<a class="lnum" href="#21" name="21">0021</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">try</span><span class="op">:</span><br />
+<a class="lnum" href="#22" name="22">0022</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">subpattern</span>&#0160;<span class="op">=</span>&#0160;<span class="name">sre_parse</span><span class="op">.</span><span class="name">SubPattern</span><span class="op">(</span><span class="name">s</span><span class="op">,</span><br />
+<a class="lnum" href="#23" name="23">0023</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="op">[</span><span class="op">(</span><span class="name">SUBPATTERN</span><span class="op">,</span>&#0160;<span class="op">(</span><span class="name">idx</span>&#0160;<span class="op">+</span>&#0160;<span class="number">1</span><span class="op">,</span>&#0160;<span class="name">sre_parse</span><span class="op">.</span><span class="name">parse</span><span class="op">(</span><span class="name">phrase</span><span class="op">,</span>&#0160;<span class="name">flags</span><span class="op">)</span><span class="op">)</span><span class="op">)</span><span class="op">]</span><span class="op">)</span><br />
+<a class="lnum" href="#24" name="24">0024</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">except</span>&#0160;<span class="name">sre_constants</span><span class="op">.</span><span class="name">error</span><span class="op">:</span><br />
+<a class="lnum" href="#25" name="25">0025</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span><br />
+<a class="lnum" href="#26" name="26">0026</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">p</span><span class="op">.</span><span class="name">append</span><span class="op">(</span><span class="name">subpattern</span><span class="op">)</span><br />
+<a class="lnum" href="#27" name="27">0027</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">actions</span><span class="op">.</span><span class="name">append</span><span class="op">(</span><span class="name">token</span><span class="op">)</span><br />
+<a class="lnum" href="#28" name="28">0028</a><br />
+<a class="lnum" href="#29" name="29">0029</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">p</span>&#0160;<span class="op">=</span>&#0160;<span class="name">sre_parse</span><span class="op">.</span><span class="name">SubPattern</span><span class="op">(</span><span class="name">s</span><span class="op">,</span>&#0160;<span class="op">[</span><span class="op">(</span><span class="name">BRANCH</span><span class="op">,</span>&#0160;<span class="op">(</span><span class="name">None</span><span class="op">,</span>&#0160;<span class="name">p</span><span class="op">)</span><span class="op">)</span><span class="op">]</span><span class="op">)</span><br />
+<a class="lnum" href="#30" name="30">0030</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">scanner</span>&#0160;<span class="op">=</span>&#0160;<span class="name">sre_compile</span><span class="op">.</span><span class="name">compile</span><span class="op">(</span><span class="name">p</span><span class="op">)</span><br />
+<a class="lnum" href="#31" name="31">0031</a><br />
+<a class="lnum" href="#32" name="32">0032</a><br />
+<a class="lnum" href="#33" name="33">0033</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">iterscan</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">string</span><span class="op">,</span>&#0160;<span class="name">idx</span><span class="op">=</span><span class="number">0</span><span class="op">,</span>&#0160;<span class="name">context</span><span class="op">=</span><span class="name">None</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#34" name="34">0034</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
+<a class="lnum" href="#35" name="35">0035</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;Yield&#0160;match,&#0160;end_idx&#0160;for&#0160;each&#0160;match</span><br />
+<a class="lnum" href="#36" name="36">0036</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;"""</span><br />
+<a class="lnum" href="#37" name="37">0037</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">match</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">scanner</span><span class="op">.</span><span class="name">scanner</span><span class="op">(</span><span class="name">string</span><span class="op">,</span>&#0160;<span class="name">idx</span><span class="op">)</span><span class="op">.</span><span class="name">match</span><br />
+<a class="lnum" href="#38" name="38">0038</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">actions</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">actions</span><br />
+<a class="lnum" href="#39" name="39">0039</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">lastend</span>&#0160;<span class="op">=</span>&#0160;<span class="name">idx</span><br />
+<a class="lnum" href="#40" name="40">0040</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">end</span>&#0160;<span class="op">=</span>&#0160;<span class="name">len</span><span class="op">(</span><span class="name">string</span><span class="op">)</span><br />
+<a class="lnum" href="#41" name="41">0041</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">while</span>&#0160;<span class="name">True</span><span class="op">:</span><br />
+<a class="lnum" href="#42" name="42">0042</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">m</span>&#0160;<span class="op">=</span>&#0160;<span class="name">match</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#43" name="43">0043</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">m</span>&#0160;<span class="keyword">is</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#44" name="44">0044</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">break</span><br />
+<a class="lnum" href="#45" name="45">0045</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">matchbegin</span><span class="op">,</span>&#0160;<span class="name">matchend</span>&#0160;<span class="op">=</span>&#0160;<span class="name">m</span><span class="op">.</span><span class="name">span</span><span class="op">(</span><span class="op">)</span><br />
+<a class="lnum" href="#46" name="46">0046</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">lastend</span>&#0160;<span class="op">==</span>&#0160;<span class="name">matchend</span><span class="op">:</span><br />
+<a class="lnum" href="#47" name="47">0047</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">break</span><br />
+<a class="lnum" href="#48" name="48">0048</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">action</span>&#0160;<span class="op">=</span>&#0160;<span class="name">actions</span><span class="op">[</span><span class="name">m</span><span class="op">.</span><span class="name">lastindex</span><span class="op">]</span><br />
+<a class="lnum" href="#49" name="49">0049</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">action</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span><span class="op">:</span><br />
+<a class="lnum" href="#50" name="50">0050</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">rval</span><span class="op">,</span>&#0160;<span class="name">next_pos</span>&#0160;<span class="op">=</span>&#0160;<span class="name">action</span><span class="op">(</span><span class="name">m</span><span class="op">,</span>&#0160;<span class="name">context</span><span class="op">)</span><br />
+<a class="lnum" href="#51" name="51">0051</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">next_pos</span>&#0160;<span class="keyword">is</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">None</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">next_pos</span>&#0160;<span class="op">!=</span>&#0160;<span class="name">matchend</span><span class="op">:</span><br />
+<a class="lnum" href="#52" name="52">0052</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;"fast&#0160;forward"&#0160;the&#0160;scanner</span><br />
+<a class="lnum" href="#53" name="53">0053</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">matchend</span>&#0160;<span class="op">=</span>&#0160;<span class="name">next_pos</span><br />
+<a class="lnum" href="#54" name="54">0054</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">match</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">scanner</span><span class="op">.</span><span class="name">scanner</span><span class="op">(</span><span class="name">string</span><span class="op">,</span>&#0160;<span class="name">matchend</span><span class="op">)</span><span class="op">.</span><span class="name">match</span><br />
+<a class="lnum" href="#55" name="55">0055</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">yield</span>&#0160;<span class="name">rval</span><span class="op">,</span>&#0160;<span class="name">matchend</span><br />
+<a class="lnum" href="#56" name="56">0056</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">lastend</span>&#0160;<span class="op">=</span>&#0160;<span class="name">matchend</span><br />
+<a class="lnum" href="#57" name="57">0057</a><br />
+<a class="lnum" href="#58" name="58">0058</a><span class="keyword">def</span>&#0160;<span class="name">pattern</span><span class="op">(</span><span class="name">pattern</span><span class="op">,</span>&#0160;<span class="name">flags</span><span class="op">=</span><span class="name">FLAGS</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#59" name="59">0059</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">decorator</span><span class="op">(</span><span class="name">fn</span><span class="op">)</span><span class="op">:</span><br />
+<a class="lnum" href="#60" name="60">0060</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">fn</span><span class="op">.</span><span class="name">pattern</span>&#0160;<span class="op">=</span>&#0160;<span class="name">pattern</span><br />
+<a class="lnum" href="#61" name="61">0061</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">fn</span><span class="op">.</span><span class="name">regex</span>&#0160;<span class="op">=</span>&#0160;<span class="name">re</span><span class="op">.</span><span class="name">compile</span><span class="op">(</span><span class="name">pattern</span><span class="op">,</span>&#0160;<span class="name">flags</span><span class="op">)</span><br />
+<a class="lnum" href="#62" name="62">0062</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">fn</span><br />
+<a class="lnum" href="#63" name="63">0063</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">decorator</span></code></div></body></html>
\ No newline at end of file
diff --git a/src/simplejson/ez_setup/README.txt b/src/simplejson/ez_setup/README.txt
new file mode 100644 (file)
index 0000000..9287f5a
--- /dev/null
@@ -0,0 +1,15 @@
+This directory exists so that Subversion-based projects can share a single
+copy of the ``ez_setup`` bootstrap module for ``setuptools``, and have it
+automatically updated in their projects when ``setuptools`` is updated.
+
+For your convenience, you may use the following svn:externals definition::
+
+    ez_setup svn://svn.eby-sarna.com/svnroot/ez_setup
+
+You can set this by executing this command in your project directory::
+
+    svn propedit svn:externals .
+
+And then adding the line shown above to the file that comes up for editing.
+Then, whenever you update your project, ``ez_setup`` will be updated as well.
+
diff --git a/src/simplejson/ez_setup/__init__.py b/src/simplejson/ez_setup/__init__.py
new file mode 100644 (file)
index 0000000..38c09c6
--- /dev/null
@@ -0,0 +1,228 @@
+#!python
+"""Bootstrap setuptools installation
+
+If you want to use setuptools in your package's setup.py, just include this
+file in the same directory with it, and add this to the top of your setup.py::
+
+    from ez_setup import use_setuptools
+    use_setuptools()
+
+If you want to require a specific version of setuptools, set a download
+mirror, or use an alternate download directory, you can do so by supplying
+the appropriate options to ``use_setuptools()``.
+
+This file can also be run as a script to install or upgrade setuptools.
+"""
+import sys
+DEFAULT_VERSION = "0.6c5"
+DEFAULT_URL     = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3]
+
+md5_data = {
+    'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
+    'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
+    'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
+    'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
+    'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
+    'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
+    'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
+    'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
+    'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
+    'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
+    'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
+    'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
+    'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa',
+    'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e',
+    'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e',
+    'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f',
+    'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2',
+    'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc',
+    'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167',
+    'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64',
+    'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d',
+}
+
+import sys, os
+
+def _validate_md5(egg_name, data):
+    if egg_name in md5_data:
+        from md5 import md5
+        digest = md5(data).hexdigest()
+        if digest != md5_data[egg_name]:
+            print >>sys.stderr, (
+                "md5 validation of %s failed!  (Possible download problem?)"
+                % egg_name
+            )
+            sys.exit(2)
+    return data
+
+
+def use_setuptools(
+    version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
+    download_delay=15
+):
+    """Automatically find/download setuptools and make it available on sys.path
+
+    `version` should be a valid setuptools version number that is available
+    as an egg for download under the `download_base` URL (which should end with
+    a '/').  `to_dir` is the directory where setuptools will be downloaded, if
+    it is not already available.  If `download_delay` is specified, it should
+    be the number of seconds that will be paused before initiating a download,
+    should one be required.  If an older version of setuptools is installed,
+    this routine will print a message to ``sys.stderr`` and raise SystemExit in
+    an attempt to abort the calling script.
+    """
+    try:
+        import setuptools
+        if setuptools.__version__ == '0.0.1':
+            print >>sys.stderr, (
+            "You have an obsolete version of setuptools installed.  Please\n"
+            "remove it from your system entirely before rerunning this script."
+            )
+            sys.exit(2)
+    except ImportError:
+        egg = download_setuptools(version, download_base, to_dir, download_delay)
+        sys.path.insert(0, egg)
+        import setuptools; setuptools.bootstrap_install_from = egg
+
+    import pkg_resources
+    try:
+        pkg_resources.require("setuptools>="+version)
+
+    except pkg_resources.VersionConflict, e:
+        # XXX could we install in a subprocess here?
+        print >>sys.stderr, (
+            "The required version of setuptools (>=%s) is not available, and\n"
+            "can't be installed while this script is running. Please install\n"
+            " a more recent version first.\n\n(Currently using %r)"
+        ) % (version, e.args[0])
+        sys.exit(2)
+
+def download_setuptools(
+    version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
+    delay = 15
+):
+    """Download setuptools from a specified location and return its filename
+
+    `version` should be a valid setuptools version number that is available
+    as an egg for download under the `download_base` URL (which should end
+    with a '/'). `to_dir` is the directory where the egg will be downloaded.
+    `delay` is the number of seconds to pause before an actual download attempt.
+    """
+    import urllib2, shutil
+    egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
+    url = download_base + egg_name
+    saveto = os.path.join(to_dir, egg_name)
+    src = dst = None
+    if not os.path.exists(saveto):  # Avoid repeated downloads
+        try:
+            from distutils import log
+            if delay:
+                log.warn("""
+---------------------------------------------------------------------------
+This script requires setuptools version %s to run (even to display
+help).  I will attempt to download it for you (from
+%s), but
+you may need to enable firewall access for this script first.
+I will start the download in %d seconds.
+
+(Note: if this machine does not have network access, please obtain the file
+
+   %s
+
+and place it in this directory before rerunning this script.)
+---------------------------------------------------------------------------""",
+                    version, download_base, delay, url
+                ); from time import sleep; sleep(delay)
+            log.warn("Downloading %s", url)
+            src = urllib2.urlopen(url)
+            # Read/write all in one block, so we don't create a corrupt file
+            # if the download is interrupted.
+            data = _validate_md5(egg_name, src.read())
+            dst = open(saveto,"wb"); dst.write(data)
+        finally:
+            if src: src.close()
+            if dst: dst.close()
+    return os.path.realpath(saveto)
+
+def main(argv, version=DEFAULT_VERSION):
+    """Install or upgrade setuptools and EasyInstall"""
+
+    try:
+        import setuptools
+    except ImportError:
+        egg = None
+        try:
+            egg = download_setuptools(version, delay=0)
+            sys.path.insert(0,egg)
+            from setuptools.command.easy_install import main
+            return main(list(argv)+[egg])   # we're done here
+        finally:
+            if egg and os.path.exists(egg):
+                os.unlink(egg)
+    else:
+        if setuptools.__version__ == '0.0.1':
+            # tell the user to uninstall obsolete version
+            use_setuptools(version)
+
+    req = "setuptools>="+version
+    import pkg_resources
+    try:
+        pkg_resources.require(req)
+    except pkg_resources.VersionConflict:
+        try:
+            from setuptools.command.easy_install import main
+        except ImportError:
+            from easy_install import main
+        main(list(argv)+[download_setuptools(delay=0)])
+        sys.exit(0) # try to force an exit
+    else:
+        if argv:
+            from setuptools.command.easy_install import main
+            main(argv)
+        else:
+            print "Setuptools version",version,"or greater has been installed."
+            print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
+
+
+
+def update_md5(filenames):
+    """Update our built-in md5 registry"""
+
+    import re
+    from md5 import md5
+
+    for name in filenames:
+        base = os.path.basename(name)
+        f = open(name,'rb')
+        md5_data[base] = md5(f.read()).hexdigest()
+        f.close()
+
+    data = ["    %r: %r,\n" % it for it in md5_data.items()]
+    data.sort()
+    repl = "".join(data)
+
+    import inspect
+    srcfile = inspect.getsourcefile(sys.modules[__name__])
+    f = open(srcfile, 'rb'); src = f.read(); f.close()
+
+    match = re.search("\nmd5_data = {\n([^}]+)}", src)
+    if not match:
+        print >>sys.stderr, "Internal error!"
+        sys.exit(2)
+
+    src = src[:match.start(1)] + repl + src[match.end(1):]
+    f = open(srcfile,'w')
+    f.write(src)
+    f.close()
+
+
+if __name__=='__main__':
+    if len(sys.argv)>2 and sys.argv[1]=='--md5update':
+        update_md5(sys.argv[2:])
+    else:
+        main(sys.argv[1:])
+
+
+
+
+
diff --git a/src/simplejson/scripts/bench.sh b/src/simplejson/scripts/bench.sh
new file mode 100644 (file)
index 0000000..e30e246
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+/usr/bin/env python -mtimeit -s 'from simplejson.tests.test_pass1 import test_parse' 'test_parse()'
diff --git a/src/simplejson/scripts/make_docs.py b/src/simplejson/scripts/make_docs.py
new file mode 100644 (file)
index 0000000..2c59032
--- /dev/null
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+import os
+import subprocess
+import shutil
+
+PROJECT='simplejson'
+
+def _get_version():
+    from pkg_resources import PathMetadata, Distribution
+    egg_info = PROJECT + '.egg-info'
+    base_dir = os.path.dirname(egg_info)
+    metadata = PathMetadata(base_dir, egg_info)
+    dist_name = os.path.splitext(os.path.basename(egg_info))[0]
+    dist = Distribution(base_dir, project_name=dist_name, metadata=metadata)
+    return dist.version
+VERSION = _get_version()
+
+PUDGE = '/Library/Frameworks/Python.framework/Versions/2.4/bin/pudge'
+#PUDGE = 'pudge'
+
+res = subprocess.call([
+    PUDGE, '-v', '-d', 'docs', '-m', PROJECT,
+    '-l', '%s %s' % (PROJECT, VERSION),
+    '--theme=green'
+])
+if not res:
+    shutil.copyfile('docs/module-simplejson.html', 'docs/index.html')
+raise SystemExit(res)
diff --git a/src/simplejson/scripts/prof.py b/src/simplejson/scripts/prof.py
new file mode 100644 (file)
index 0000000..45c7a85
--- /dev/null
@@ -0,0 +1,9 @@
+#!/usr/bin/env python2.4
+from pkg_resources import require
+require('simplejson')
+
+import profile
+
+from simplejson.tests.test_pass1 import test_parse
+
+profile.run("for x in xrange(10): test_parse()")
diff --git a/src/simplejson/setup.cfg b/src/simplejson/setup.cfg
new file mode 100644 (file)
index 0000000..861a9f5
--- /dev/null
@@ -0,0 +1,5 @@
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/src/simplejson/setup.py b/src/simplejson/setup.py
new file mode 100644 (file)
index 0000000..83d160c
--- /dev/null
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+
+import ez_setup
+ez_setup.use_setuptools()
+
+from setuptools import setup, find_packages, Extension, Feature
+from distutils.command.build_ext import build_ext
+from distutils.errors import CCompilerError
+
+VERSION = '1.7.1'
+DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python"
+LONG_DESCRIPTION = """
+simplejson is a simple, fast, complete, correct and extensible
+JSON <http://json.org> encoder and decoder for Python 2.3+.  It is
+pure Python code with no dependencies, but includes an optional C
+extension for a serious speed boost.
+
+simplejson was formerly known as simple_json, but changed its name to
+comply with PEP 8 module naming guidelines.
+
+The encoder may be subclassed to provide serialization in any kind of
+situation, without any special support by the objects to be serialized
+(somewhat like pickle).
+
+The decoder can handle incoming JSON strings of any specified encoding
+(UTF-8 by default).
+"""
+
+CLASSIFIERS = filter(None, map(str.strip,
+"""                 
+Intended Audience :: Developers
+License :: OSI Approved :: MIT License
+Programming Language :: Python
+Topic :: Software Development :: Libraries :: Python Modules
+""".splitlines()))
+
+
+BUILD_EXT_WARNING="""
+WARNING: The C extension could not be compiled, speedups are not enabled.
+
+Above is the output showing how the compilation failed.
+"""
+
+class ve_build_ext(build_ext):
+    # This class allows C extension building to fail.
+    def build_extension(self, ext):
+        try:
+            build_ext.build_extension(self, ext)
+        except CCompilerError, x:
+            print ('*'*70+'\n')
+            print BUILD_EXT_WARNING
+            print ('*'*70+'\n')
+
+speedups = Feature(
+    "options C speed-enhancement modules",
+    standard=True,
+    ext_modules = [
+        Extension("simplejson._speedups", ["simplejson/_speedups.c"]),
+    ],
+)
+
+setup(
+    name="simplejson",
+    version=VERSION,
+    description=DESCRIPTION,
+    long_description=LONG_DESCRIPTION,
+    classifiers=CLASSIFIERS,
+    author="Bob Ippolito",
+    author_email="bob@redivi.com",
+    url="http://undefined.org/python/#simplejson",
+    license="MIT License",
+    packages=find_packages(exclude=['ez_setup']),
+    platforms=['any'],
+    test_suite="nose.collector",
+    zip_safe=True,
+    entry_points={
+        'paste.filter_app_factory': ['json = simplejson.jsonfilter:factory'],
+    },
+    features={'speedups': speedups},
+    cmdclass={'build_ext': ve_build_ext},
+)
diff --git a/src/simplejson/simplejson.egg-info/PKG-INFO b/src/simplejson/simplejson.egg-info/PKG-INFO
new file mode 100644 (file)
index 0000000..c202c5f
--- /dev/null
@@ -0,0 +1,29 @@
+Metadata-Version: 1.0
+Name: simplejson
+Version: 1.7.1
+Summary: Simple, fast, extensible JSON encoder/decoder for Python
+Home-page: http://undefined.org/python/#simplejson
+Author: Bob Ippolito
+Author-email: bob@redivi.com
+License: MIT License
+Description: 
+        simplejson is a simple, fast, complete, correct and extensible
+        JSON <http://json.org> encoder and decoder for Python 2.3+.  It is
+        pure Python code with no dependencies, but includes an optional C
+        extension for a serious speed boost.
+        
+        simplejson was formerly known as simple_json, but changed its name to
+        comply with PEP 8 module naming guidelines.
+        
+        The encoder may be subclassed to provide serialization in any kind of
+        situation, without any special support by the objects to be serialized
+        (somewhat like pickle).
+        
+        The decoder can handle incoming JSON strings of any specified encoding
+        (UTF-8 by default).
+        
+Platform: any
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Programming Language :: Python
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/src/simplejson/simplejson.egg-info/SOURCES.txt b/src/simplejson/simplejson.egg-info/SOURCES.txt
new file mode 100644 (file)
index 0000000..7e0139f
--- /dev/null
@@ -0,0 +1,46 @@
+LICENSE.txt
+setup.cfg
+setup.py
+docs/class-simplejson.JSONDecoder.html
+docs/class-simplejson.JSONEncoder.html
+docs/class_to_source.js
+docs/index.html
+docs/layout.css
+docs/module-index.html
+docs/module-simplejson-index.html
+docs/module-simplejson.html
+docs/pudge.css
+docs/rst.css
+docs/simplejson/__init__.py.html
+docs/simplejson/decoder.py.html
+docs/simplejson/encoder.py.html
+docs/simplejson/jsonfilter.py.html
+docs/simplejson/scanner.py.html
+ez_setup/README.txt
+ez_setup/__init__.py
+scripts/bench.sh
+scripts/make_docs.py
+scripts/prof.py
+simplejson/__init__.py
+simplejson/_speedups.c
+simplejson/decoder.py
+simplejson/encoder.py
+simplejson/jsonfilter.py
+simplejson/scanner.py
+simplejson.egg-info/PKG-INFO
+simplejson.egg-info/SOURCES.txt
+simplejson.egg-info/dependency_links.txt
+simplejson.egg-info/entry_points.txt
+simplejson.egg-info/top_level.txt
+simplejson.egg-info/zip-safe
+simplejson/tests/__init__.py
+simplejson/tests/test_attacks.py
+simplejson/tests/test_dump.py
+simplejson/tests/test_fail.py
+simplejson/tests/test_indent.py
+simplejson/tests/test_pass1.py
+simplejson/tests/test_pass2.py
+simplejson/tests/test_pass3.py
+simplejson/tests/test_recursion.py
+simplejson/tests/test_separators.py
+simplejson/tests/test_unicode.py
diff --git a/src/simplejson/simplejson.egg-info/dependency_links.txt b/src/simplejson/simplejson.egg-info/dependency_links.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/src/simplejson/simplejson.egg-info/entry_points.txt b/src/simplejson/simplejson.egg-info/entry_points.txt
new file mode 100644 (file)
index 0000000..e08f296
--- /dev/null
@@ -0,0 +1,3 @@
+[paste.filter_app_factory]
+json = simplejson.jsonfilter:factory
+
diff --git a/src/simplejson/simplejson.egg-info/top_level.txt b/src/simplejson/simplejson.egg-info/top_level.txt
new file mode 100644 (file)
index 0000000..322630e
--- /dev/null
@@ -0,0 +1 @@
+simplejson
diff --git a/src/simplejson/simplejson.egg-info/zip-safe b/src/simplejson/simplejson.egg-info/zip-safe
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/src/simplejson/simplejson/__init__.py b/src/simplejson/simplejson/__init__.py
new file mode 100644 (file)
index 0000000..8dae51a
--- /dev/null
@@ -0,0 +1,287 @@
+r"""
+A simple, fast, extensible JSON encoder and decoder
+
+JSON (JavaScript Object Notation) <http://json.org> is a subset of
+JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data
+interchange format.
+
+simplejson exposes an API familiar to uses of the standard library
+marshal and pickle modules.
+
+Encoding basic Python object hierarchies::
+    
+    >>> import simplejson
+    >>> simplejson.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
+    '["foo", {"bar": ["baz", null, 1.0, 2]}]'
+    >>> print simplejson.dumps("\"foo\bar")
+    "\"foo\bar"
+    >>> print simplejson.dumps(u'\u1234')
+    "\u1234"
+    >>> print simplejson.dumps('\\')
+    "\\"
+    >>> print simplejson.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True)
+    {"a": 0, "b": 0, "c": 0}
+    >>> from StringIO import StringIO
+    >>> io = StringIO()
+    >>> simplejson.dump(['streaming API'], io)
+    >>> io.getvalue()
+    '["streaming API"]'
+
+Compact encoding::
+
+    >>> import simplejson
+    >>> simplejson.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',',':'))
+    '[1,2,3,{"4":5,"6":7}]'
+
+Pretty printing::
+
+    >>> import simplejson
+    >>> print simplejson.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4)
+    {
+        "4": 5, 
+        "6": 7
+    }
+
+Decoding JSON::
+    
+    >>> import simplejson
+    >>> simplejson.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
+    [u'foo', {u'bar': [u'baz', None, 1.0, 2]}]
+    >>> simplejson.loads('"\\"foo\\bar"')
+    u'"foo\x08ar'
+    >>> from StringIO import StringIO
+    >>> io = StringIO('["streaming API"]')
+    >>> simplejson.load(io)
+    [u'streaming API']
+
+Specializing JSON object decoding::
+
+    >>> import simplejson
+    >>> def as_complex(dct):
+    ...     if '__complex__' in dct:
+    ...         return complex(dct['real'], dct['imag'])
+    ...     return dct
+    ... 
+    >>> simplejson.loads('{"__complex__": true, "real": 1, "imag": 2}',
+    ...     object_hook=as_complex)
+    (1+2j)
+
+Extending JSONEncoder::
+    
+    >>> import simplejson
+    >>> class ComplexEncoder(simplejson.JSONEncoder):
+    ...     def default(self, obj):
+    ...         if isinstance(obj, complex):
+    ...             return [obj.real, obj.imag]
+    ...         return simplejson.JSONEncoder.default(self, obj)
+    ... 
+    >>> dumps(2 + 1j, cls=ComplexEncoder)
+    '[2.0, 1.0]'
+    >>> ComplexEncoder().encode(2 + 1j)
+    '[2.0, 1.0]'
+    >>> list(ComplexEncoder().iterencode(2 + 1j))
+    ['[', '2.0', ', ', '1.0', ']']
+    
+
+Note that the JSON produced by this module's default settings
+is a subset of YAML, so it may be used as a serializer for that as well.
+"""
+__version__ = '1.7.1'
+__all__ = [
+    'dump', 'dumps', 'load', 'loads',
+    'JSONDecoder', 'JSONEncoder',
+]
+
+from decoder import JSONDecoder
+from encoder import JSONEncoder
+
+_default_encoder = JSONEncoder(
+    skipkeys=False,
+    ensure_ascii=True,
+    check_circular=True,
+    allow_nan=True,
+    indent=None,
+    separators=None,
+    encoding='utf-8'
+)
+
+def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True,
+        allow_nan=True, cls=None, indent=None, separators=None,
+        encoding='utf-8', **kw):
+    """
+    Serialize ``obj`` as a JSON formatted stream to ``fp`` (a
+    ``.write()``-supporting file-like object).
+
+    If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic types
+    (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``) 
+    will be skipped instead of raising a ``TypeError``.
+
+    If ``ensure_ascii`` is ``False``, then the some chunks written to ``fp``
+    may be ``unicode`` instances, subject to normal Python ``str`` to
+    ``unicode`` coercion rules. Unless ``fp.write()`` explicitly
+    understands ``unicode`` (as in ``codecs.getwriter()``) this is likely
+    to cause an error.
+
+    If ``check_circular`` is ``False``, then the circular reference check
+    for container types will be skipped and a circular reference will
+    result in an ``OverflowError`` (or worse).
+
+    If ``allow_nan`` is ``False``, then it will be a ``ValueError`` to
+    serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``)
+    in strict compliance of the JSON specification, instead of using the
+    JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).
+
+    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 ``separators`` is an ``(item_separator, dict_separator)`` tuple
+    then it will be used instead of the default ``(', ', ': ')`` separators.
+    ``(',', ':')`` is the most compact JSON representation.
+
+    ``encoding`` is the character encoding for str instances, default is UTF-8.
+
+    To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
+    ``.default()`` method to serialize additional types), specify it with
+    the ``cls`` kwarg.
+    """
+    # cached encoder
+    if (skipkeys is False and ensure_ascii is True and
+        check_circular is True and allow_nan is True and
+        cls is None and indent is None and separators is None and
+        encoding == 'utf-8' and not kw):
+        iterable = _default_encoder.iterencode(obj)
+    else:
+        if cls is None:
+            cls = JSONEncoder
+        iterable = cls(skipkeys=skipkeys, ensure_ascii=ensure_ascii,
+            check_circular=check_circular, allow_nan=allow_nan, indent=indent,
+            separators=separators, encoding=encoding, **kw).iterencode(obj)
+    # could accelerate with writelines in some versions of Python, at
+    # a debuggability cost
+    for chunk in iterable:
+        fp.write(chunk)
+
+
+def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True,
+        allow_nan=True, cls=None, indent=None, separators=None,
+        encoding='utf-8', **kw):
+    """
+    Serialize ``obj`` to a JSON formatted ``str``.
+
+    If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic types
+    (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``) 
+    will be skipped instead of raising a ``TypeError``.
+
+    If ``ensure_ascii`` is ``False``, then the return value will be a
+    ``unicode`` instance subject to normal Python ``str`` to ``unicode``
+    coercion rules instead of being escaped to an ASCII ``str``.
+
+    If ``check_circular`` is ``False``, then the circular reference check
+    for container types will be skipped and a circular reference will
+    result in an ``OverflowError`` (or worse).
+
+    If ``allow_nan`` is ``False``, then it will be a ``ValueError`` to
+    serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) in
+    strict compliance of the JSON specification, instead of using the
+    JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).
+
+    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 ``separators`` is an ``(item_separator, dict_separator)`` tuple
+    then it will be used instead of the default ``(', ', ': ')`` separators.
+    ``(',', ':')`` is the most compact JSON representation.
+
+    ``encoding`` is the character encoding for str instances, default is UTF-8.
+
+    To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
+    ``.default()`` method to serialize additional types), specify it with
+    the ``cls`` kwarg.
+    """
+    # cached encoder
+    if (skipkeys is False and ensure_ascii is True and
+        check_circular is True and allow_nan is True and
+        cls is None and indent is None and separators is None and
+        encoding == 'utf-8' and not kw):
+        return _default_encoder.encode(obj)
+    if cls is None:
+        cls = JSONEncoder
+    return cls(
+        skipkeys=skipkeys, ensure_ascii=ensure_ascii,
+        check_circular=check_circular, allow_nan=allow_nan, indent=indent,
+        separators=separators, encoding=encoding,
+        **kw).encode(obj)
+
+_default_decoder = JSONDecoder(encoding=None, object_hook=None)
+
+def load(fp, encoding=None, cls=None, object_hook=None, **kw):
+    """
+    Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
+    a JSON document) to a Python object.
+
+    If the contents of ``fp`` is encoded with an ASCII based encoding other
+    than utf-8 (e.g. latin-1), then an appropriate ``encoding`` name must
+    be specified. Encodings that are not ASCII based (such as UCS-2) are
+    not allowed, and should be wrapped with
+    ``codecs.getreader(fp)(encoding)``, or simply decoded to a ``unicode``
+    object and passed to ``loads()``
+
+    ``object_hook`` is an optional function that will be called with the
+    result of any object literal decode (a ``dict``). The return value of
+    ``object_hook`` will be used instead of the ``dict``. This feature
+    can be used to implement custom decoders (e.g. JSON-RPC class hinting).
+    
+    To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
+    kwarg.
+    """
+    return loads(fp.read(),
+        encoding=encoding, cls=cls, object_hook=object_hook, **kw)
+
+def loads(s, encoding=None, cls=None, object_hook=None, **kw):
+    """
+    Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a JSON
+    document) to a Python object.
+
+    If ``s`` is a ``str`` instance and is encoded with an ASCII based encoding
+    other than utf-8 (e.g. latin-1) then an appropriate ``encoding`` name
+    must be specified. Encodings that are not ASCII based (such as UCS-2)
+    are not allowed and should be decoded to ``unicode`` first.
+
+    ``object_hook`` is an optional function that will be called with the
+    result of any object literal decode (a ``dict``). The return value of
+    ``object_hook`` will be used instead of the ``dict``. This feature
+    can be used to implement custom decoders (e.g. JSON-RPC class hinting).
+
+    To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
+    kwarg.
+    """
+    if cls is None and encoding is None and object_hook is None and not kw:
+        return _default_decoder.decode(s)
+    if cls is None:
+        cls = JSONDecoder
+    if object_hook is not None:
+        kw['object_hook'] = object_hook
+    return cls(encoding=encoding, **kw).decode(s)
+
+def read(s):
+    """
+    json-py API compatibility hook. Use loads(s) instead.
+    """
+    import warnings
+    warnings.warn("simplejson.loads(s) should be used instead of read(s)",
+        DeprecationWarning)
+    return loads(s)
+
+def write(obj):
+    """
+    json-py API compatibility hook. Use dumps(s) instead.
+    """
+    import warnings
+    warnings.warn("simplejson.dumps(s) should be used instead of write(s)",
+        DeprecationWarning)
+    return dumps(obj)
+
+
diff --git a/src/simplejson/simplejson/_speedups.c b/src/simplejson/simplejson/_speedups.c
new file mode 100644 (file)
index 0000000..8f290bb
--- /dev/null
@@ -0,0 +1,215 @@
+#include "Python.h"
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+#define PY_SSIZE_T_MAX INT_MAX
+#define PY_SSIZE_T_MIN INT_MIN
+#endif
+
+static Py_ssize_t
+ascii_escape_char(Py_UNICODE c, char *output, Py_ssize_t chars);
+static PyObject *
+ascii_escape_unicode(PyObject *pystr);
+static PyObject *
+ascii_escape_str(PyObject *pystr);
+static PyObject *
+py_encode_basestring_ascii(PyObject* self __attribute__((__unused__)), PyObject *pystr);
+void init_speedups(void);
+
+#define S_CHAR(c) (c >= ' ' && c <= '~' && c != '\\' && c != '/' && c != '"')
+
+#define MIN_EXPANSION 6
+#ifdef Py_UNICODE_WIDE
+#define MAX_EXPANSION (2 * MIN_EXPANSION)
+#else
+#define MAX_EXPANSION MIN_EXPANSION
+#endif
+
+static Py_ssize_t
+ascii_escape_char(Py_UNICODE c, char *output, Py_ssize_t chars) {
+    Py_UNICODE x;
+    output[chars++] = '\\';
+    switch (c) {
+        case '/': output[chars++] = (char)c; break;
+        case '\\': output[chars++] = (char)c; break;
+        case '"': output[chars++] = (char)c; break;
+        case '\b': output[chars++] = 'b'; break;
+        case '\f': output[chars++] = 'f'; break;
+        case '\n': output[chars++] = 'n'; break;
+        case '\r': output[chars++] = 'r'; break;
+        case '\t': output[chars++] = 't'; break;
+        default:
+#ifdef Py_UNICODE_WIDE
+            if (c >= 0x10000) {
+                /* UTF-16 surrogate pair */
+                Py_UNICODE v = c - 0x10000;
+                c = 0xd800 | ((v >> 10) & 0x3ff);
+                output[chars++] = 'u';
+                x = (c & 0xf000) >> 12;
+                output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+                x = (c & 0x0f00) >> 8;
+                output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+                x = (c & 0x00f0) >> 4;
+                output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+                x = (c & 0x000f);
+                output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+                c = 0xdc00 | (v & 0x3ff);
+                output[chars++] = '\\';
+            }
+#endif
+            output[chars++] = 'u';
+            x = (c & 0xf000) >> 12;
+            output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+            x = (c & 0x0f00) >> 8;
+            output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+            x = (c & 0x00f0) >> 4;
+            output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+            x = (c & 0x000f);
+            output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+    }
+    return chars;
+}
+
+static PyObject *
+ascii_escape_unicode(PyObject *pystr) {
+    Py_ssize_t i;
+    Py_ssize_t input_chars;
+    Py_ssize_t output_size;
+    Py_ssize_t chars;
+    PyObject *rval;
+    char *output;
+    Py_UNICODE *input_unicode;
+
+    input_chars = PyUnicode_GET_SIZE(pystr);
+    input_unicode = PyUnicode_AS_UNICODE(pystr);
+    /* One char input can be up to 6 chars output, estimate 4 of these */
+    output_size = 2 + (MIN_EXPANSION * 4) + input_chars;
+    rval = PyString_FromStringAndSize(NULL, output_size);
+    if (rval == NULL) {
+        return NULL;
+    }
+    output = PyString_AS_STRING(rval);
+    chars = 0;
+    output[chars++] = '"';
+    for (i = 0; i < input_chars; i++) {
+        Py_UNICODE c = input_unicode[i];
+        if (S_CHAR(c)) {
+            output[chars++] = (char)c;
+        } else {
+            chars = ascii_escape_char(c, output, chars);
+        }
+        if (output_size - chars < (1 + MAX_EXPANSION)) {
+            /* There's more than four, so let's resize by a lot */
+            output_size *= 2;
+            /* This is an upper bound */
+            if (output_size > 2 + (input_chars * MAX_EXPANSION)) {
+                output_size = 2 + (input_chars * MAX_EXPANSION);
+            }
+            if (_PyString_Resize(&rval, output_size) == -1) {
+                return NULL;
+            }
+            output = PyString_AS_STRING(rval);
+        }
+    }
+    output[chars++] = '"';
+    if (_PyString_Resize(&rval, chars) == -1) {
+        return NULL;
+    }
+    return rval;
+}
+
+static PyObject *
+ascii_escape_str(PyObject *pystr) {
+    Py_ssize_t i;
+    Py_ssize_t input_chars;
+    Py_ssize_t output_size;
+    Py_ssize_t chars;
+    PyObject *rval;
+    char *output;
+    char *input_str;
+
+    input_chars = PyString_GET_SIZE(pystr);
+    input_str = PyString_AS_STRING(pystr);
+    /* One char input can be up to 6 chars output, estimate 4 of these */
+    output_size = 2 + (MIN_EXPANSION * 4) + input_chars;
+    rval = PyString_FromStringAndSize(NULL, output_size);
+    if (rval == NULL) {
+        return NULL;
+    }
+    output = PyString_AS_STRING(rval);
+    chars = 0;
+    output[chars++] = '"';
+    for (i = 0; i < input_chars; i++) {
+        Py_UNICODE c = (Py_UNICODE)input_str[i];
+        if (S_CHAR(c)) {
+            output[chars++] = (char)c;
+        } else if (c > 0x7F) {
+            /* We hit a non-ASCII character, bail to unicode mode */
+            PyObject *uni;
+            Py_DECREF(rval);
+            uni = PyUnicode_DecodeUTF8(input_str, input_chars, "strict");
+            if (uni == NULL) {
+                return NULL;
+            }
+            rval = ascii_escape_unicode(uni);
+            Py_DECREF(uni);
+            return rval;
+        } else {
+            chars = ascii_escape_char(c, output, chars);
+        }
+        /* An ASCII char can't possibly expand to a surrogate! */
+        if (output_size - chars < (1 + MIN_EXPANSION)) {
+            /* There's more than four, so let's resize by a lot */
+            output_size *= 2;
+            if (output_size > 2 + (input_chars * MIN_EXPANSION)) {
+                output_size = 2 + (input_chars * MIN_EXPANSION);
+            }
+            if (_PyString_Resize(&rval, output_size) == -1) {
+                return NULL;
+            }
+            output = PyString_AS_STRING(rval);
+        }
+    }
+    output[chars++] = '"';
+    if (_PyString_Resize(&rval, chars) == -1) {
+        return NULL;
+    }
+    return rval;
+}
+
+PyDoc_STRVAR(pydoc_encode_basestring_ascii,
+    "encode_basestring_ascii(basestring) -> str\n"
+    "\n"
+    "..."
+);
+
+static PyObject *
+py_encode_basestring_ascii(PyObject* self __attribute__((__unused__)), PyObject *pystr) {
+    /* METH_O */
+    if (PyString_Check(pystr)) {
+        return ascii_escape_str(pystr);
+    } else if (PyUnicode_Check(pystr)) {
+        return ascii_escape_unicode(pystr);
+    }
+    PyErr_SetString(PyExc_TypeError, "first argument must be a string");
+    return NULL;
+}
+
+#define DEFN(n, k) \
+    {  \
+        #n, \
+        (PyCFunction)py_ ##n, \
+        k, \
+        pydoc_ ##n \
+    }
+static PyMethodDef speedups_methods[] = {
+    DEFN(encode_basestring_ascii, METH_O),
+    {}
+};
+#undef DEFN
+
+void
+init_speedups(void)
+{
+    PyObject *m;
+    m = Py_InitModule4("_speedups", speedups_methods, NULL, NULL, PYTHON_API_VERSION);
+}
diff --git a/src/simplejson/simplejson/decoder.py b/src/simplejson/simplejson/decoder.py
new file mode 100644 (file)
index 0000000..a1b53b2
--- /dev/null
@@ -0,0 +1,273 @@
+"""
+Implementation of JSONDecoder
+"""
+import re
+
+from simplejson.scanner import Scanner, pattern
+
+FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
+
+def _floatconstants():
+    import struct
+    import sys
+    _BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
+    if sys.byteorder != 'big':
+        _BYTES = _BYTES[:8][::-1] + _BYTES[8:][::-1]
+    nan, inf = struct.unpack('dd', _BYTES)
+    return nan, inf, -inf
+
+NaN, PosInf, NegInf = _floatconstants()
+
+def linecol(doc, pos):
+    lineno = doc.count('\n', 0, pos) + 1
+    if lineno == 1:
+        colno = pos
+    else:
+        colno = pos - doc.rindex('\n', 0, pos)
+    return lineno, colno
+
+def errmsg(msg, doc, pos, end=None):
+    lineno, colno = linecol(doc, pos)
+    if end is None:
+        return '%s: line %d column %d (char %d)' % (msg, lineno, colno, pos)
+    endlineno, endcolno = linecol(doc, end)
+    return '%s: line %d column %d - line %d column %d (char %d - %d)' % (
+        msg, lineno, colno, endlineno, endcolno, pos, end)
+
+_CONSTANTS = {
+    '-Infinity': NegInf,
+    'Infinity': PosInf,
+    'NaN': NaN,
+    'true': True,
+    'false': False,
+    'null': None,
+}
+
+def JSONConstant(match, context, c=_CONSTANTS):
+    return c[match.group(0)], None
+pattern('(-?Infinity|NaN|true|false|null)')(JSONConstant)
+
+def JSONNumber(match, context):
+    match = JSONNumber.regex.match(match.string, *match.span())
+    integer, frac, exp = match.groups()
+    if frac or exp:
+        res = float(integer + (frac or '') + (exp or ''))
+    else:
+        res = int(integer)
+    return res, None
+pattern(r'(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?')(JSONNumber)
+
+STRINGCHUNK = re.compile(r'(.*?)(["\\])', FLAGS)
+BACKSLASH = {
+    '"': u'"', '\\': u'\\', '/': u'/',
+    'b': u'\b', 'f': u'\f', 'n': u'\n', 'r': u'\r', 't': u'\t',
+}
+
+DEFAULT_ENCODING = "utf-8"
+
+def scanstring(s, end, encoding=None, _b=BACKSLASH, _m=STRINGCHUNK.match):
+    if encoding is None:
+        encoding = DEFAULT_ENCODING
+    chunks = []
+    _append = chunks.append
+    begin = end - 1
+    while 1:
+        chunk = _m(s, end)
+        if chunk is None:
+            raise ValueError(
+                errmsg("Unterminated string starting at", s, begin))
+        end = chunk.end()
+        content, terminator = chunk.groups()
+        if content:
+            if not isinstance(content, unicode):
+                content = unicode(content, encoding)
+            _append(content)
+        if terminator == '"':
+            break
+        try:
+            esc = s[end]
+        except IndexError:
+            raise ValueError(
+                errmsg("Unterminated string starting at", s, begin))
+        if esc != 'u':
+            try:
+                m = _b[esc]
+            except KeyError:
+                raise ValueError(
+                    errmsg("Invalid \\escape: %r" % (esc,), s, end))
+            end += 1
+        else:
+            esc = s[end + 1:end + 5]
+            try:
+                m = unichr(int(esc, 16))
+                if len(esc) != 4 or not esc.isalnum():
+                    raise ValueError
+            except ValueError:
+                raise ValueError(errmsg("Invalid \\uXXXX escape", s, end))
+            end += 5
+        _append(m)
+    return u''.join(chunks), end
+
+def JSONString(match, context):
+    encoding = getattr(context, 'encoding', None)
+    return scanstring(match.string, match.end(), encoding)
+pattern(r'"')(JSONString)
+
+WHITESPACE = re.compile(r'\s*', FLAGS)
+
+def JSONObject(match, context, _w=WHITESPACE.match):
+    pairs = {}
+    s = match.string
+    end = _w(s, match.end()).end()
+    nextchar = s[end:end + 1]
+    # trivial empty object
+    if nextchar == '}':
+        return pairs, end + 1
+    if nextchar != '"':
+        raise ValueError(errmsg("Expecting property name", s, end))
+    end += 1
+    encoding = getattr(context, 'encoding', None)
+    iterscan = JSONScanner.iterscan
+    while True:
+        key, end = scanstring(s, end, encoding)
+        end = _w(s, end).end()
+        if s[end:end + 1] != ':':
+            raise ValueError(errmsg("Expecting : delimiter", s, end))
+        end = _w(s, end + 1).end()
+        try:
+            value, end = iterscan(s, idx=end, context=context).next()
+        except StopIteration:
+            raise ValueError(errmsg("Expecting object", s, end))
+        pairs[key] = value
+        end = _w(s, end).end()
+        nextchar = s[end:end + 1]
+        end += 1
+        if nextchar == '}':
+            break
+        if nextchar != ',':
+            raise ValueError(errmsg("Expecting , delimiter", s, end - 1))
+        end = _w(s, end).end()
+        nextchar = s[end:end + 1]
+        end += 1
+        if nextchar != '"':
+            raise ValueError(errmsg("Expecting property name", s, end - 1))
+    object_hook = getattr(context, 'object_hook', None)
+    if object_hook is not None:
+        pairs = object_hook(pairs)
+    return pairs, end
+pattern(r'{')(JSONObject)
+            
+def JSONArray(match, context, _w=WHITESPACE.match):
+    values = []
+    s = match.string
+    end = _w(s, match.end()).end()
+    # look-ahead for trivial empty array
+    nextchar = s[end:end + 1]
+    if nextchar == ']':
+        return values, end + 1
+    iterscan = JSONScanner.iterscan
+    while True:
+        try:
+            value, end = iterscan(s, idx=end, context=context).next()
+        except StopIteration:
+            raise ValueError(errmsg("Expecting object", s, end))
+        values.append(value)
+        end = _w(s, end).end()
+        nextchar = s[end:end + 1]
+        end += 1
+        if nextchar == ']':
+            break
+        if nextchar != ',':
+            raise ValueError(errmsg("Expecting , delimiter", s, end))
+        end = _w(s, end).end()
+    return values, end
+pattern(r'\[')(JSONArray)
+ANYTHING = [
+    JSONObject,
+    JSONArray,
+    JSONString,
+    JSONConstant,
+    JSONNumber,
+]
+
+JSONScanner = Scanner(ANYTHING)
+
+class JSONDecoder(object):
+    """
+    Simple JSON <http://json.org> decoder
+
+    Performs the following translations in decoding:
+    
+    +---------------+-------------------+
+    | JSON          | Python            |
+    +===============+===================+
+    | object        | dict              |
+    +---------------+-------------------+
+    | array         | list              |
+    +---------------+-------------------+
+    | string        | unicode           |
+    +---------------+-------------------+
+    | number (int)  | int, long         |
+    +---------------+-------------------+
+    | number (real) | float             |
+    +---------------+-------------------+
+    | true          | True              |
+    +---------------+-------------------+
+    | false         | False             |
+    +---------------+-------------------+
+    | null          | None              |
+    +---------------+-------------------+
+
+    It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
+    their corresponding ``float`` values, which is outside the JSON spec.
+    """
+
+    _scanner = Scanner(ANYTHING)
+    __all__ = ['__init__', 'decode', 'raw_decode']
+
+    def __init__(self, encoding=None, object_hook=None):
+        """
+        ``encoding`` determines the encoding used to interpret any ``str``
+        objects decoded by this instance (utf-8 by default).  It has no
+        effect when decoding ``unicode`` objects.
+        
+        Note that currently only encodings that are a superset of ASCII work,
+        strings of other encodings should be passed in as ``unicode``.
+
+        ``object_hook``, if specified, will be called with the result
+        of every JSON object decoded and its return value will be used in
+        place of the given ``dict``.  This can be used to provide custom
+        deserializations (e.g. to support JSON-RPC class hinting).
+        """
+        self.encoding = encoding
+        self.object_hook = object_hook
+
+    def decode(self, s, _w=WHITESPACE.match):
+        """
+        Return the Python representation of ``s`` (a ``str`` or ``unicode``
+        instance containing a JSON document)
+        """
+        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
+        end = _w(s, end).end()
+        if end != len(s):
+            raise ValueError(errmsg("Extra data", s, end, len(s)))
+        return obj
+
+    def raw_decode(self, s, **kw):
+        """
+        Decode a JSON document from ``s`` (a ``str`` or ``unicode`` beginning
+        with a JSON document) and return a 2-tuple of the Python
+        representation and the index in ``s`` where the document ended.
+
+        This can be used to decode a JSON document from a string that may
+        have extraneous data at the end.
+        """
+        kw.setdefault('context', self)
+        try:
+            obj, end = self._scanner.iterscan(s, **kw).next()
+        except StopIteration:
+            raise ValueError("No JSON object could be decoded")
+        return obj, end
+
+__all__ = ['JSONDecoder']
diff --git a/src/simplejson/simplejson/encoder.py b/src/simplejson/simplejson/encoder.py
new file mode 100644 (file)
index 0000000..eec9c7f
--- /dev/null
@@ -0,0 +1,371 @@
+"""
+Implementation of JSONEncoder
+"""
+import re
+try:
+    from simplejson import _speedups
+except ImportError:
+    _speedups = None
+
+ESCAPE = re.compile(r'[\x00-\x19\\"\b\f\n\r\t]')
+ESCAPE_ASCII = re.compile(r'([\\"/]|[^\ -~])')
+ESCAPE_DCT = {
+    # escape all forward slashes to prevent </script> attack
+    '/': '\\/',
+    '\\': '\\\\',
+    '"': '\\"',
+    '\b': '\\b',
+    '\f': '\\f',
+    '\n': '\\n',
+    '\r': '\\r',
+    '\t': '\\t',
+}
+for i in range(0x20):
+    ESCAPE_DCT.setdefault(chr(i), '\\u%04x' % (i,))
+
+# assume this produces an infinity on all machines (probably not guaranteed)
+INFINITY = float('1e66666')
+
+def floatstr(o, allow_nan=True):
+    # Check for specials.  Note that this type of test is processor- and/or
+    # platform-specific, so do tests which don't depend on the internals.
+
+    if o != o:
+        text = 'NaN'
+    elif o == INFINITY:
+        text = 'Infinity'
+    elif o == -INFINITY:
+        text = '-Infinity'
+    else:
+        return str(o)
+
+    if not allow_nan:
+        raise ValueError("Out of range float values are not JSON compliant: %r"
+            % (o,))
+
+    return text
+
+
+def encode_basestring(s):
+    """
+    Return a JSON representation of a Python string
+    """
+    def replace(match):
+        return ESCAPE_DCT[match.group(0)]
+    return '"' + ESCAPE.sub(replace, s) + '"'
+
+def encode_basestring_ascii(s):
+    def replace(match):
+        s = match.group(0)
+        try:
+            return ESCAPE_DCT[s]
+        except KeyError:
+            n = ord(s)
+            if n < 0x10000:
+                return '\\u%04x' % (n,)
+            else:
+                # surrogate pair
+                n -= 0x10000
+                s1 = 0xd800 | ((n >> 10) & 0x3ff)
+                s2 = 0xdc00 | (n & 0x3ff)
+                return '\\u%04x\\u%04x' % (s1, s2)
+    return '"' + str(ESCAPE_ASCII.sub(replace, s)) + '"'
+        
+try:
+    encode_basestring_ascii = _speedups.encode_basestring_ascii
+    _need_utf8 = True
+except AttributeError:
+    _need_utf8 = False
+
+class JSONEncoder(object):
+    """
+    Extensible JSON <http://json.org> 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``).
+    """
+    __all__ = ['__init__', 'default', 'encode', 'iterencode']
+    item_separator = ', '
+    key_separator = ': '
+    def __init__(self, skipkeys=False, ensure_ascii=True,
+            check_circular=True, allow_nan=True, sort_keys=False,
+            indent=None, separators=None, encoding='utf-8'):
+        """
+        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 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.
+        """
+
+        self.skipkeys = skipkeys
+        self.ensure_ascii = ensure_ascii
+        self.check_circular = check_circular
+        self.allow_nan = allow_nan
+        self.sort_keys = sort_keys
+        self.indent = indent
+        self.current_indent_level = 0
+        if separators is not None:
+            self.item_separator, self.key_separator = separators
+        self.encoding = encoding
+
+    def _newline_indent(self):
+        return '\n' + (' ' * (self.indent * self.current_indent_level))
+
+    def _iterencode_list(self, lst, markers=None):
+        if not lst:
+            yield '[]'
+            return
+        if markers is not None:
+            markerid = id(lst)
+            if markerid in markers:
+                raise ValueError("Circular reference detected")
+            markers[markerid] = lst
+        yield '['
+        if self.indent is not None:
+            self.current_indent_level += 1
+            newline_indent = self._newline_indent()
+            separator = self.item_separator + newline_indent
+            yield newline_indent
+        else:
+            newline_indent = None
+            separator = self.item_separator
+        first = True
+        for value in lst:
+            if first:
+                first = False
+            else:
+                yield separator
+            for chunk in self._iterencode(value, markers):
+                yield chunk
+        if newline_indent is not None:
+            self.current_indent_level -= 1
+            yield self._newline_indent()
+        yield ']'
+        if markers is not None:
+            del markers[markerid]
+
+    def _iterencode_dict(self, dct, markers=None):
+        if not dct:
+            yield '{}'
+            return
+        if markers is not None:
+            markerid = id(dct)
+            if markerid in markers:
+                raise ValueError("Circular reference detected")
+            markers[markerid] = dct
+        yield '{'
+        key_separator = self.key_separator
+        if self.indent is not None:
+            self.current_indent_level += 1
+            newline_indent = self._newline_indent()
+            item_separator = self.item_separator + newline_indent
+            yield newline_indent
+        else:
+            newline_indent = None
+            item_separator = self.item_separator
+        first = True
+        if self.ensure_ascii:
+            encoder = encode_basestring_ascii
+        else:
+            encoder = encode_basestring
+        allow_nan = self.allow_nan
+        if self.sort_keys:
+            keys = dct.keys()
+            keys.sort()
+            items = [(k, dct[k]) for k in keys]
+        else:
+            items = dct.iteritems()
+        _encoding = self.encoding
+        _do_decode = (_encoding is not None
+            and not (_need_utf8 and _encoding == 'utf-8'))
+        for key, value in items:
+            if isinstance(key, str):
+                if _do_decode:
+                    key = key.decode(_encoding)
+            elif isinstance(key, basestring):
+                pass
+            # JavaScript is weakly typed for these, so it makes sense to
+            # also allow them.  Many encoders seem to do something like this.
+            elif isinstance(key, float):
+                key = floatstr(key, allow_nan)
+            elif isinstance(key, (int, long)):
+                key = str(key)
+            elif key is True:
+                key = 'true'
+            elif key is False:
+                key = 'false'
+            elif key is None:
+                key = 'null'
+            elif self.skipkeys:
+                continue
+            else:
+                raise TypeError("key %r is not a string" % (key,))
+            if first:
+                first = False
+            else:
+                yield item_separator
+            yield encoder(key)
+            yield key_separator
+            for chunk in self._iterencode(value, markers):
+                yield chunk
+        if newline_indent is not None:
+            self.current_indent_level -= 1
+            yield self._newline_indent()
+        yield '}'
+        if markers is not None:
+            del markers[markerid]
+
+    def _iterencode(self, o, markers=None):
+        if isinstance(o, basestring):
+            if self.ensure_ascii:
+                encoder = encode_basestring_ascii
+            else:
+                encoder = encode_basestring
+            _encoding = self.encoding
+            if (_encoding is not None and isinstance(o, str)
+                    and not (_need_utf8 and _encoding == 'utf-8')):
+                o = o.decode(_encoding)
+            yield encoder(o)
+        elif o is None:
+            yield 'null'
+        elif o is True:
+            yield 'true'
+        elif o is False:
+            yield 'false'
+        elif isinstance(o, (int, long)):
+            yield str(o)
+        elif isinstance(o, float):
+            yield floatstr(o, self.allow_nan)
+        elif isinstance(o, (list, tuple)):
+            for chunk in self._iterencode_list(o, markers):
+                yield chunk
+        elif isinstance(o, dict):
+            for chunk in self._iterencode_dict(o, markers):
+                yield chunk
+        else:
+            if markers is not None:
+                markerid = id(o)
+                if markerid in markers:
+                    raise ValueError("Circular reference detected")
+                markers[markerid] = o
+            for chunk in self._iterencode_default(o, markers):
+                yield chunk
+            if markers is not None:
+                del markers[markerid]
+
+    def _iterencode_default(self, o, markers=None):
+        newobj = self.default(o)
+        return self._iterencode(newobj, markers)
+
+    def default(self, o):
+        """
+        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)
+                return JSONEncoder.default(self, o)
+        """
+        raise TypeError("%r is not JSON serializable" % (o,))
+
+    def encode(self, o):
+        """
+        Return a JSON string representation of a Python data structure.
+
+        >>> JSONEncoder().encode({"foo": ["bar", "baz"]})
+        '{"foo":["bar", "baz"]}'
+        """
+        # This is for extremely simple cases and benchmarks...
+        if isinstance(o, basestring):
+            if isinstance(o, str):
+                _encoding = self.encoding
+                if (_encoding is not None 
+                        and not (_encoding == 'utf-8' and _need_utf8)):
+                    o = o.decode(_encoding)
+            return encode_basestring_ascii(o)
+        # This doesn't pass the iterator directly to ''.join() because it
+        # sucks at reporting exceptions.  It's going to do this internally
+        # anyway because it uses PySequence_Fast or similar.
+        chunks = list(self.iterencode(o))
+        return ''.join(chunks)
+
+    def iterencode(self, o):
+        """
+        Encode the given object and yield each string
+        representation as available.
+        
+        For example::
+            
+            for chunk in JSONEncoder().iterencode(bigobject):
+                mysocket.write(chunk)
+        """
+        if self.check_circular:
+            markers = {}
+        else:
+            markers = None
+        return self._iterencode(o, markers)
+
+__all__ = ['JSONEncoder']
diff --git a/src/simplejson/simplejson/jsonfilter.py b/src/simplejson/simplejson/jsonfilter.py
new file mode 100644 (file)
index 0000000..01ca21d
--- /dev/null
@@ -0,0 +1,40 @@
+import simplejson
+import cgi
+
+class JSONFilter(object):
+    def __init__(self, app, mime_type='text/x-json'):
+        self.app = app
+        self.mime_type = mime_type
+
+    def __call__(self, environ, start_response):
+        # Read JSON POST input to jsonfilter.json if matching mime type
+        response = {'status': '200 OK', 'headers': []}
+        def json_start_response(status, headers):
+            response['status'] = status
+            response['headers'].extend(headers)
+        environ['jsonfilter.mime_type'] = self.mime_type
+        if environ.get('REQUEST_METHOD', '') == 'POST':
+            if environ.get('CONTENT_TYPE', '') == self.mime_type:
+                args = [_ for _ in [environ.get('CONTENT_LENGTH')] if _]
+                data = environ['wsgi.input'].read(*map(int, args))
+                environ['jsonfilter.json'] = simplejson.loads(data)
+        res = simplejson.dumps(self.app(environ, json_start_response))
+        jsonp = cgi.parse_qs(environ.get('QUERY_STRING', '')).get('jsonp')
+        if jsonp:
+            content_type = 'text/javascript'
+            res = ''.join(jsonp + ['(', res, ')'])
+        elif 'Opera' in environ.get('HTTP_USER_AGENT', ''):
+            # Opera has bunk XMLHttpRequest support for most mime types
+            content_type = 'text/plain'
+        else:
+            content_type = self.mime_type
+        headers = [
+            ('Content-type', content_type),
+            ('Content-length', len(res)),
+        ]
+        headers.extend(response['headers'])
+        start_response(response['status'], headers)
+        return [res]
+
+def factory(app, global_conf, **kw):
+    return JSONFilter(app, **kw)
diff --git a/src/simplejson/simplejson/scanner.py b/src/simplejson/simplejson/scanner.py
new file mode 100644 (file)
index 0000000..64f4999
--- /dev/null
@@ -0,0 +1,63 @@
+"""
+Iterator based sre token scanner
+"""
+import sre_parse, sre_compile, sre_constants
+from sre_constants import BRANCH, SUBPATTERN
+from re import VERBOSE, MULTILINE, DOTALL
+import re
+
+__all__ = ['Scanner', 'pattern']
+
+FLAGS = (VERBOSE | MULTILINE | DOTALL)
+class Scanner(object):
+    def __init__(self, lexicon, flags=FLAGS):
+        self.actions = [None]
+        # combine phrases into a compound pattern
+        s = sre_parse.Pattern()
+        s.flags = flags
+        p = []
+        for idx, token in enumerate(lexicon):
+            phrase = token.pattern
+            try:
+                subpattern = sre_parse.SubPattern(s,
+                    [(SUBPATTERN, (idx + 1, sre_parse.parse(phrase, flags)))])
+            except sre_constants.error:
+                raise
+            p.append(subpattern)
+            self.actions.append(token)
+
+        p = sre_parse.SubPattern(s, [(BRANCH, (None, p))])
+        self.scanner = sre_compile.compile(p)
+
+
+    def iterscan(self, string, idx=0, context=None):
+        """
+        Yield match, end_idx for each match
+        """
+        match = self.scanner.scanner(string, idx).match
+        actions = self.actions
+        lastend = idx
+        end = len(string)
+        while True:
+            m = match()
+            if m is None:
+                break
+            matchbegin, matchend = m.span()
+            if lastend == matchend:
+                break
+            action = actions[m.lastindex]
+            if action is not None:
+                rval, next_pos = action(m, context)
+                if next_pos is not None and next_pos != matchend:
+                    # "fast forward" the scanner
+                    matchend = next_pos
+                    match = self.scanner.scanner(string, matchend).match
+                yield rval, matchend
+            lastend = matchend
+            
+def pattern(pattern, flags=FLAGS):
+    def decorator(fn):
+        fn.pattern = pattern
+        fn.regex = re.compile(pattern, flags)
+        return fn
+    return decorator
diff --git a/src/simplejson/simplejson/tests/__init__.py b/src/simplejson/simplejson/tests/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/simplejson/simplejson/tests/test_attacks.py b/src/simplejson/simplejson/tests/test_attacks.py
new file mode 100644 (file)
index 0000000..8ecfed8
--- /dev/null
@@ -0,0 +1,6 @@
+def test_script_close_attack():
+    import simplejson
+    res = simplejson.dumps('</script>')
+    assert '</script>' not in res
+    res = simplejson.dumps(simplejson.loads('"</script>"'))
+    assert '</script>' not in res
diff --git a/src/simplejson/simplejson/tests/test_dump.py b/src/simplejson/simplejson/tests/test_dump.py
new file mode 100644 (file)
index 0000000..b4e236e
--- /dev/null
@@ -0,0 +1,10 @@
+from cStringIO import StringIO
+import simplejson as S
+
+def test_dump():
+    sio = StringIO()
+    S.dump({}, sio)
+    assert sio.getvalue() == '{}'
+    
+def test_dumps():
+    assert S.dumps({}) == '{}'
diff --git a/src/simplejson/simplejson/tests/test_fail.py b/src/simplejson/simplejson/tests/test_fail.py
new file mode 100644 (file)
index 0000000..a99d9c4
--- /dev/null
@@ -0,0 +1,70 @@
+# Fri Dec 30 18:57:26 2005
+JSONDOCS = [
+    # http://json.org/JSON_checker/test/fail1.json
+    '"A JSON payload should be an object or array, not a string."',
+    # http://json.org/JSON_checker/test/fail2.json
+    '["Unclosed array"',
+    # http://json.org/JSON_checker/test/fail3.json
+    '{unquoted_key: "keys must be quoted}',
+    # http://json.org/JSON_checker/test/fail4.json
+    '["extra comma",]',
+    # http://json.org/JSON_checker/test/fail5.json
+    '["double extra comma",,]',
+    # http://json.org/JSON_checker/test/fail6.json
+    '[   , "<-- missing value"]',
+    # http://json.org/JSON_checker/test/fail7.json
+    '["Comma after the close"],',
+    # http://json.org/JSON_checker/test/fail8.json
+    '["Extra close"]]',
+    # http://json.org/JSON_checker/test/fail9.json
+    '{"Extra comma": true,}',
+    # http://json.org/JSON_checker/test/fail10.json
+    '{"Extra value after close": true} "misplaced quoted value"',
+    # http://json.org/JSON_checker/test/fail11.json
+    '{"Illegal expression": 1 + 2}',
+    # http://json.org/JSON_checker/test/fail12.json
+    '{"Illegal invocation": alert()}',
+    # http://json.org/JSON_checker/test/fail13.json
+    '{"Numbers cannot have leading zeroes": 013}',
+    # http://json.org/JSON_checker/test/fail14.json
+    '{"Numbers cannot be hex": 0x14}',
+    # http://json.org/JSON_checker/test/fail15.json
+    '["Illegal backslash escape: \\x15"]',
+    # http://json.org/JSON_checker/test/fail16.json
+    '["Illegal backslash escape: \\\'"]',
+    # http://json.org/JSON_checker/test/fail17.json
+    '["Illegal backslash escape: \\017"]',
+    # http://json.org/JSON_checker/test/fail18.json
+    '[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]',
+    # http://json.org/JSON_checker/test/fail19.json
+    '{"Missing colon" null}',
+    # http://json.org/JSON_checker/test/fail20.json
+    '{"Double colon":: null}',
+    # http://json.org/JSON_checker/test/fail21.json
+    '{"Comma instead of colon", null}',
+    # http://json.org/JSON_checker/test/fail22.json
+    '["Colon instead of comma": false]',
+    # http://json.org/JSON_checker/test/fail23.json
+    '["Bad value", truth]',
+    # http://json.org/JSON_checker/test/fail24.json
+    "['single quote']",
+]
+
+SKIPS = {
+    1: "why not have a string payload?",
+    18: "spec doesn't specify any nesting limitations",
+}
+
+def test_failures():
+    import simplejson
+    for idx, doc in enumerate(JSONDOCS):
+        idx = idx + 1
+        if idx in SKIPS:
+            simplejson.loads(doc)
+            continue
+        try:
+            simplejson.loads(doc)
+        except ValueError:
+            pass
+        else:
+            assert False, "Expected failure for fail%d.json: %r" % (idx, doc)
diff --git a/src/simplejson/simplejson/tests/test_indent.py b/src/simplejson/simplejson/tests/test_indent.py
new file mode 100644 (file)
index 0000000..47dd4dc
--- /dev/null
@@ -0,0 +1,41 @@
+
+
+
+def test_indent():
+    import simplejson
+    import textwrap
+    
+    h = [['blorpie'], ['whoops'], [], 'd-shtaeou', 'd-nthiouh', 'i-vhbjkhnth',
+         {'nifty': 87}, {'field': 'yes', 'morefield': False} ]
+
+    expect = textwrap.dedent("""\
+    [
+      [
+        "blorpie"
+      ],
+      [
+        "whoops"
+      ],
+      [],
+      "d-shtaeou",
+      "d-nthiouh",
+      "i-vhbjkhnth",
+      {
+        "nifty": 87
+      },
+      {
+        "field": "yes",
+        "morefield": false
+      }
+    ]""")
+
+
+    d1 = simplejson.dumps(h)
+    d2 = simplejson.dumps(h, indent=2, sort_keys=True, separators=(',', ': '))
+
+    h1 = simplejson.loads(d1)
+    h2 = simplejson.loads(d2)
+
+    assert h1 == h
+    assert h2 == h
+    assert d2 == expect
diff --git a/src/simplejson/simplejson/tests/test_pass1.py b/src/simplejson/simplejson/tests/test_pass1.py
new file mode 100644 (file)
index 0000000..4eda192
--- /dev/null
@@ -0,0 +1,72 @@
+# from http://json.org/JSON_checker/test/pass1.json
+JSON = r'''
+[
+    "JSON Test Pattern pass1",
+    {"object with 1 member":["array with 1 element"]},
+    {},
+    [],
+    -42,
+    true,
+    false,
+    null,
+    {
+        "integer": 1234567890,
+        "real": -9876.543210,
+        "e": 0.123456789e-12,
+        "E": 1.234567890E+34,
+        "":  23456789012E666,
+        "zero": 0,
+        "one": 1,
+        "space": " ",
+        "quote": "\"",
+        "backslash": "\\",
+        "controls": "\b\f\n\r\t",
+        "slash": "/ & \/",
+        "alpha": "abcdefghijklmnopqrstuvwyz",
+        "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
+        "digit": "0123456789",
+        "special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?",
+        "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
+        "true": true,
+        "false": false,
+        "null": null,
+        "array":[  ],
+        "object":{  },
+        "address": "50 St. James Street",
+        "url": "http://www.JSON.org/",
+        "comment": "// /* <!-- --",
+        "# -- --> */": " ",
+        " s p a c e d " :[1,2 , 3
+
+,
+
+4 , 5        ,          6           ,7        ],
+        "compact": [1,2,3,4,5,6,7],
+        "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
+        "quotes": "&#34; \u0022 %22 0x22 034 &#x22;",
+        "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"
+: "A key can be any string"
+    },
+    0.5 ,98.6
+,
+99.44
+,
+
+1066
+
+
+,"rosebud"]
+'''
+
+def test_parse():
+    # test in/out equivalence and parsing
+    import simplejson
+    res = simplejson.loads(JSON)
+    out = simplejson.dumps(res)
+    assert res == simplejson.loads(out)
+    try:
+        simplejson.dumps(res, allow_nan=False)
+    except ValueError:
+        pass
+    else:
+        assert False, "23456789012E666 should be out of range"
diff --git a/src/simplejson/simplejson/tests/test_pass2.py b/src/simplejson/simplejson/tests/test_pass2.py
new file mode 100644 (file)
index 0000000..ae74abb
--- /dev/null
@@ -0,0 +1,11 @@
+# from http://json.org/JSON_checker/test/pass2.json
+JSON = r'''
+[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
+'''
+
+def test_parse():
+    # test in/out equivalence and parsing
+    import simplejson
+    res = simplejson.loads(JSON)
+    out = simplejson.dumps(res)
+    assert res == simplejson.loads(out)
diff --git a/src/simplejson/simplejson/tests/test_pass3.py b/src/simplejson/simplejson/tests/test_pass3.py
new file mode 100644 (file)
index 0000000..d94893f
--- /dev/null
@@ -0,0 +1,16 @@
+# from http://json.org/JSON_checker/test/pass3.json
+JSON = r'''
+{
+    "JSON Test Pattern pass3": {
+        "The outermost value": "must be an object or array.",
+        "In this test": "It is an object."
+    }
+}
+'''
+
+def test_parse():
+    # test in/out equivalence and parsing
+    import simplejson
+    res = simplejson.loads(JSON)
+    out = simplejson.dumps(res)
+    assert res == simplejson.loads(out)
diff --git a/src/simplejson/simplejson/tests/test_recursion.py b/src/simplejson/simplejson/tests/test_recursion.py
new file mode 100644 (file)
index 0000000..756b066
--- /dev/null
@@ -0,0 +1,62 @@
+import simplejson
+
+def test_listrecursion():
+    x = []
+    x.append(x)
+    try:
+        simplejson.dumps(x)
+    except ValueError:
+        pass
+    else:
+        assert False, "didn't raise ValueError on list recursion"
+    x = []
+    y = [x]
+    x.append(y)
+    try:
+        simplejson.dumps(x)
+    except ValueError:
+        pass
+    else:
+        assert False, "didn't raise ValueError on alternating list recursion"
+    y = []
+    x = [y, y]
+    # ensure that the marker is cleared
+    simplejson.dumps(x)
+
+def test_dictrecursion():
+    x = {}
+    x["test"] = x
+    try:
+        simplejson.dumps(x)
+    except ValueError:
+        pass
+    else:
+        assert False, "didn't raise ValueError on dict recursion"
+    x = {}
+    y = {"a": x, "b": x}
+    # ensure that the marker is cleared
+    simplejson.dumps(x)
+
+class TestObject:
+    pass
+
+class RecursiveJSONEncoder(simplejson.JSONEncoder):
+    recurse = False
+    def default(self, o):
+        if o is TestObject:
+            if self.recurse:
+                return [TestObject]
+            else:
+                return 'TestObject'
+        simplejson.JSONEncoder.default(o)
+
+def test_defaultrecursion():
+    enc = RecursiveJSONEncoder()
+    assert enc.encode(TestObject) == '"TestObject"'
+    enc.recurse = True
+    try:
+        enc.encode(TestObject)
+    except ValueError:
+        pass
+    else:
+        assert False, "didn't raise ValueError on default recursion"
diff --git a/src/simplejson/simplejson/tests/test_separators.py b/src/simplejson/simplejson/tests/test_separators.py
new file mode 100644 (file)
index 0000000..a615354
--- /dev/null
@@ -0,0 +1,41 @@
+
+
+
+def test_separators():
+    import simplejson
+    import textwrap
+    
+    h = [['blorpie'], ['whoops'], [], 'd-shtaeou', 'd-nthiouh', 'i-vhbjkhnth',
+         {'nifty': 87}, {'field': 'yes', 'morefield': False} ]
+
+    expect = textwrap.dedent("""\
+    [
+      [
+        "blorpie"
+      ] ,
+      [
+        "whoops"
+      ] ,
+      [] ,
+      "d-shtaeou" ,
+      "d-nthiouh" ,
+      "i-vhbjkhnth" ,
+      {
+        "nifty" : 87
+      } ,
+      {
+        "field" : "yes" ,
+        "morefield" : false
+      }
+    ]""")
+
+
+    d1 = simplejson.dumps(h)
+    d2 = simplejson.dumps(h, indent=2, sort_keys=True, separators=(' ,', ' : '))
+
+    h1 = simplejson.loads(d1)
+    h2 = simplejson.loads(d2)
+
+    assert h1 == h
+    assert h2 == h
+    assert d2 == expect
diff --git a/src/simplejson/simplejson/tests/test_unicode.py b/src/simplejson/simplejson/tests/test_unicode.py
new file mode 100644 (file)
index 0000000..88d0939
--- /dev/null
@@ -0,0 +1,16 @@
+import simplejson as S
+
+def test_encoding1():
+    encoder = S.JSONEncoder(encoding='utf-8')
+    u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
+    s = u.encode('utf-8')
+    ju = encoder.encode(u)
+    js = encoder.encode(s)
+    assert ju == js
+    
+def test_encoding2():
+    u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
+    s = u.encode('utf-8')
+    ju = S.dumps(u, encoding='utf-8')
+    js = S.dumps(s, encoding='utf-8')
+    assert ju == js