You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to read JSON from a stream using the New().Reader() method (I'm using the docker api). I want to read the same JSON value which will be continuously updated in a for loop. Using the following code my output is empty and my program will just hang in the loop forever.
Maybe I'm misunderstanding, but the return value of Find("myKey") is just an interface no? So it has no method Reset(). However, I tried calling jq.Reset() inside the loop, but with no effect. I believe the problem is that the JSONQ.Reader() calls ReadFrom() on resp.Body (in the case of my example). ReadFrom() seems to read until EOF which the stream I'm giving as input will not do until it is manually stopped or crashes.
I think the implementation of Decoder.Decode() from encoding/json uses an approach where the buffer is parsed one element at a time, and not until EOF. I managed to get my desired result with the following snippet. Could a similar feature be considered added to gojsonq?
I'm trying to read JSON from a stream using the
New().Reader()
method (I'm using the docker api). I want to read the same JSON value which will be continuously updated in a for loop. Using the following code my output is empty and my program will just hang in the loop forever.For the sake of the example my JSON is just:
The text was updated successfully, but these errors were encountered: