Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:: [': 0.04; 'json': 0.07; 'subject:ANN': 0.07; 'obj': 0.09; 'objects:': 0.09; 'clark': 0.16; 'dashes': 0.16; 'skip:j 60': 0.16; 'to:name:python list': 0.16; 'yaml': 0.16; 'wrote:': 0.18; 'wed,': 0.18; '>>>': 0.22; 'print': 0.22; '>>>': 0.24; 'processor': 0.24; 'skip:{ 20': 0.24; 'looks': 0.24; '---': 0.24; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'doc': 0.31; 'url:python': 0.33; 'third': 0.33; 'could': 0.34; 'received:google.com': 0.35; 'add': 0.35; '8bit%:9': 0.36; 'url:listinfo': 0.36; "didn't": 0.36; 'method': 0.36; 'url:org': 0.36; 'skip:& 10': 0.38; 'handle': 0.38; 'to:addr :python-list': 0.38; 'skip:& 20': 0.39; 'to:addr:python.org': 0.39; 'space': 0.40; 'url:mail': 0.40; 'more': 0.64; 'between': 0.67; 'useful.': 0.68; 'jul': 0.74; 'processor.': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=wkKI2sOo9XgiX250ISt3lHNbT+hy1tVIGUljP7HyOMU=; b=Sxmy4TlDi0eLgp6dMLRychIK+oGZ+5iuUnW6yQHMzvuk+RGL7f4ieCuSU7zQShMKqm Ig/Brj2KXxL66Lvcd+OyqxxDbdmkguOdi1EcNtqNuV3aSkr+eIGJjoS6Wty50lb595ot 1MwF0GXn6NaqiyIYG6LUbDmpcK76gWm3M4hgtmadWGddYP32+k13IcELO545G/m/C3lC wwzT4ZCJjuHh9IPVC17s1CrwM7+ZHpF2xqvjLtI8llfqidZhiF1yjz/l9RG/fyv7rEkZ omqWgdelCGaRUTme1Y2pTWRxrvEIxmf0TvfTONlv9G3sNs3ahI9n450YUWVhOiGK6FQr wIMw== MIME-Version: 1.0 X-Received: by 10.68.217.170 with SMTP id oz10mr8397225pbc.152.1374089758559; Wed, 17 Jul 2013 12:35:58 -0700 (PDT) In-Reply-To: <1374076300.20300.140661256765729.2467B0A8@webmail.messagingengine.com> References: <1374076300.20300.140661256765729.2467B0A8@webmail.messagingengine.com> Date: Wed, 17 Jul 2013 15:35:58 -0400 Subject: Re: [ANN]:JSONStream From: Sol Toure To: Python List Content-Type: multipart/alternative; boundary=047d7b2ed9b3f2f02404e1ba3368 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 102 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374089767 news.xs4all.nl 15941 [2001:888:2000:d::a6]:42119 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50799 --047d7b2ed9b3f2f02404e1ba3368 Content-Type: text/plain; charset=UTF-8 I didn't look into using YAML processor. Also that would have required pre-processing the data to add the separators. With this method you don't need the separators. You can have 0 or more white space between objects: for obj in JSONStream(StringIO('''{"one":1}{"two":2} {"three":3} 4 {"five": 5}''')): print(obj) {"one":1} {"two":2} {"three":3} 4 {"five":5} It solved my problem, so I thought someone might find it useful. On Wed, Jul 17, 2013 at 11:51 AM, Clark C. Evans wrote: > ** > Looks interesting. In YAML we used three dashes as the "stream separator". > So already a YAML processor could handle a JSON stream ... > > >>> for doc in yaml.load_all(""" > ... --- {"one": "value"} > ... --- {"two": "another"} > ... --- > ... {"three": "a third item in the stream", > ... "with": "more data"} > ... """): > ... print doc > ... > {'one': 'value'} > {'two': 'another'} > {'with': 'more data', 'three': 'a third item in the stream'} > > > > -- > http://mail.python.org/mailman/listinfo/python-list > > --047d7b2ed9b3f2f02404e1ba3368 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I didn't look into using YAML processor.
Also= that would have required pre-processing the data to add the separators.
With this method you don't need the separators. You can hav= e 0 or more white space between objects:

for obj in JSONStream(StringIO('''{"one&quo= t;:1}{"two":2}=C2=A0=C2=A0=C2=A0 {"three":3} 4 {"f= ive": 5}''')):
=C2=A0 print(obj)

{"one":1}
{"two":2}
{"three":3}
4
=
{"five":5}

It solved my problem, so = I thought someone might find it useful.



On Wed, Jul 17, 2013 at 11:51 AM, Clark = C. Evans <cce@clarkevans.com> wrote:
Looks interesting.=C2=A0 In YAML we used three dashes as the &quo= t;stream separator".
So already a YAML processor could handle a JSON stream ...
=C2=A0
>>> for doc in yaml.load_all("""
... --- {"one": "value"}
... --- {"two": "another"}
... ---
... {"three": "a third item in the stream",
...=C2=A0 "with": "more data"}
... """):
...=C2=A0=C2=A0=C2=A0=C2=A0 print doc
...
{'one': 'value'}
{'two': 'another'}
{'with': 'more data', 'three': 'a third it= em in the stream'}
=C2=A0
=C2=A0

--
http://mail.python.org/mailman/listinfo/python-list


--047d7b2ed9b3f2f02404e1ba3368--