Closed DAddYE closed 9 years ago
I think I found the issue. I had to use the bufio
See: https://github.com/DAddYE/json-test/commit/7a85b6de2dbc4e893e785c2260abb451fd4d979e
Exactly. encoding/json internally creates a buffered reader internally. The problem is that it will end up reading more than is necessary for the json structure from the reader. It makes it hard to have a stream of multiple structures i.e. a multi-content stream.
codec instead expects that the user will handle buffering themselves, so will never read more than is necessary for its decoding. It thus allows you have a stream that contains a header, then multiple content streams with possible different encoding formats in sequence e.g.
It totally makes sense to me and I appreciated that
I made a quick test, source here: https://github.com/DAddYE/json-test
I'm pretty sure somewhere there is an error (maybe in my code?) but the speed of codec-json is very slow compared to the one in the standard library.
Installed codec with: