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


Groups > comp.lang.python > #50799 > unrolled thread

Re: [ANN]:JSONStream

Started bySol Toure <sol2ray@gmail.com>
First post2013-07-17 15:35 -0400
Last post2013-07-17 15:35 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [ANN]:JSONStream Sol Toure <sol2ray@gmail.com> - 2013-07-17 15:35 -0400

#50799 — Re: [ANN]:JSONStream

FromSol Toure <sol2ray@gmail.com>
Date2013-07-17 15:35 -0400
SubjectRe: [ANN]:JSONStream
Message-ID<mailman.4809.1374089767.3114.python-list@python.org>

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

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'}
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web