I've tried this suggestion and although its certainly a bit more
refactoring then I expected - the outcome looks to be exactly as you
described here.
Thank you so much for the suggestion, take a bow!
- Greg
On Sunday, March 28, 2021 at 12:15:34 PM UTC-7 Brian Candler wrote:
> No, it's even simpler than that:
>
> * The first call to decoder.Decode() will return the first object in the
> stream.
> * The second call to decoder.Decode() will return the second object in the
> stream.
> * And so on...
>
> By "object" I mean top-level object: everything between the opening "{"
> and its matching closing "}", including all its nested values. (Define a
> struct which contains all the nested attributes, for it to be deserialized
> into).
>
> If an io.Reader stream consists of a series of separate JSON objects - as
> yours does - then you get one object at a time. They don't have to be
> separated by whitespace or newlines, but they can be.
>
> Don't think about seeking. I don't know the internals of
> decoder.Decode(), but I would expect that it reads in chunks from the
> io.Reader. This means it will likely overshoot the object boundaries, but
> will buffer the excess and process it on the next call to Decode.
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/d3d1a980-deeb-4d03-afca-65e32a242bb9n%40googlegroups.com.