Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #50801

Re: [ANN]:JSONStream

References <CACGSewf0J3SPNssM-iJPg1Rthj+_wJe1p-fGe4_FcgxHGiJu0A@mail.gmail.com> <1374076300.20300.140661256765729.2467B0A8@webmail.messagingengine.com> <CACGSewcX15=dRsEZkdaPbe71dff5XS5ENVR-+6SiRJ0+E4iLqQ@mail.gmail.com>
Date 2013-07-17 20:45 +0100
Subject Re: [ANN]:JSONStream
From Fábio Santos <fabiosantosart@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.4811.1374090316.3114.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 17 Jul 2013 20:40, "Sol Toure" <sol2ray@gmail.com> wrote:
>
> 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 <cce@clarkevans.com>
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'}

I think this could be useful for the twitter stream api. It feeds
\n-separated json objects over time.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: [ANN]:JSONStream Fábio Santos <fabiosantosart@gmail.com> - 2013-07-17 20:45 +0100

csiph-web