Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json-iterator/go is not 100% compatible drop-in replacement of encoding/json #229

Open
choleraehyq opened this issue Jan 28, 2018 · 7 comments

Comments

@choleraehyq
Copy link

choleraehyq commented Jan 28, 2018

Several functions missing. Like Compact/Indent/HTMLEscape/Decoder.Token etc.

@choleraehyq choleraehyq changed the title Missing Compact/Indent/HTMLEscape comparing to encoding/json json-iterator/go is not 100% compatible drop-in replacement of encoding/json Jan 28, 2018
@taowen
Copy link
Contributor

taowen commented Jan 28, 2018

no one is asking for them

@veqryn
Copy link

veqryn commented Jul 23, 2018

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
}

@carbocation
Copy link

The readme says "100% compatibility with standard lib". I think that if this line were removed, this issue could be resolved...

@shatil
Copy link

shatil commented Oct 20, 2018

#313 relates to this. jsoniter doesn't support the Umarshaler interface: https://golang.org/pkg/encoding/json/#Unmarshaler

@jszwedko
Copy link

jszwedko commented Apr 13, 2020

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.

@Dentrax
Copy link

Dentrax commented Apr 18, 2023

no one is asking for them

Any updates on this? I'm asking. 👋 I'm just hit this issue. 🙈

@damnever
Copy link

damnever commented May 5, 2023

Another issue: #657

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants