json-iterator/go is not 100% compatible drop-in replacement of encoding/json
choleraehyq opened this issue ยท 7 comments
Several functions missing. Like Compact/Indent/HTMLEscape/Decoder.Token etc.
no one is asking for them
HTML Escaping is supported through the following, I think:
func jsonIteratorMarshalAddNewLineNoEscapeHTML(v interface{}) ([]byte, error) {
buffer := &bytes.Buffer{}
encoder := jsonIterator.NewEncoder(buffer)
encoder.SetEscapeHTML(false)
err := encoder.Encode(v)
return buffer.Bytes(), err
}
The readme says "100% compatibility with standard lib". I think that if this line were removed, this issue could be resolved...
#313 relates to this. jsoniter
doesn't support the Umarshaler
interface: https://golang.org/pkg/encoding/json/#Unmarshaler
I agree that the README should be updated to convey which parts are not compatible with encoding/json
and not say "100% compatible". There are a couple functions missing from the Decoder
type:
func (dec *Decoder) InputOffset() int64
func (dec *Decoder) Token() (Token, error)
I had wanted to try out switching to json-iterator/go
, but our code currently depends on these functions for one of our packages that does stream processing of documents and I was surprised to find them missing given the claim of drop-in compatibility.
no one is asking for them
Any updates on this? I'm asking. ๐ I'm just hit this issue. ๐