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
The issue for Decoder.More() has been resolved, thank you! Unfortunately, now when reading from socket with the code in #261 the end of the stream starts to throw
ReadMapCB: expect { or n, but found , error found in #10 byte of ...|"1000000"}
|..., bigger context ...|"999998"}
{"count": "999999"}
{"count": "1000000"}
|...
Upon adding some more debugging code, it seems that Decoder.More() is returning true at the end of the stream
Updated code:
# for i in {0..1000000}; do echo "{\"count\": \"$i\"}" >> 1mjson; done
# nc localhost 1234 < 1mjson
package main
import (
"fmt"
"net"
"github.com/json-iterator/go"
)
var json = jsoniter.ConfigCompatibleWithStandardLibrary
func main() {
addr := ":1234"
tcpAddr, _ := net.ResolveTCPAddr("tcp4", addr)
listener, _ := net.ListenTCP("tcp", tcpAddr)
for {
conn, err := listener.Accept()
if err != nil {
continue
}
go func(conn net.Conn) {
defer conn.Close()
jsonReader := json.NewDecoder(conn)
for jsonReader.More() {
var jsonMsg map[string]interface{}
err := jsonReader.Decode(&jsonMsg)
if err != nil {
fmt.Printf("Decoder.More(): %v\n", jsonReader.More())
fmt.Println(err)
}
fmt.Println(jsonMsg)
}
fmt.Println("Deferred close of connection executing")
}(conn)
}
}
Updated output:
Decoder.More(): true
ReadMapCB: expect { or n, but found , error found in #10 byte of ...|"1000000"}
|..., bigger context ...|"999998"}
{"count": "999999"}
{"count": "1000000"}
|...
I've worked around this temporarily by just returning on err != nil, but it would be awesome to have this bug squashed too
Thanks!
The text was updated successfully, but these errors were encountered:
The issue for Decoder.More() has been resolved, thank you! Unfortunately, now when reading from socket with the code in #261 the end of the stream starts to throw
Upon adding some more debugging code, it seems that Decoder.More() is returning true at the end of the stream
Updated code:
Updated output:
I've worked around this temporarily by just returning on err != nil, but it would be awesome to have this bug squashed too
Thanks!
The text was updated successfully, but these errors were encountered: