Do the Token and More methods on json.Decoder not fit your use case?
There’s an example in the std lib docs: https://golang.org/pkg/encoding/json/#example_Decoder_Decode_stream.
--
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 golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
For this kind of use case, it would be very nice if the decoder made the following promise: If given a bufio.Reader in the constructor (with at least XX size buffer), when the decoder has just finished successfully decoding a top-level JSON value, it will leave the reader positioned just after the last character of that value. This should be doable using UnreadByte and/or UnreadRune and, if necessary, Peek. I don't think Peek will be necessary.If the above promise were made, then the OP's request would be as simple as: create bufio.Reader and json.Decoder, loop until EOF (read RS character; unmarshal JSON value with decoder; read LF character).
The point of the separators is to enable resynchronization in cases where JSON records are truncated or corrupted. Just replacing the RS with whitespace would defeat that.