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

Probable Unicode conversion #252

Closed
rbkumar88 opened this issue Aug 6, 2019 · 2 comments
Closed

Probable Unicode conversion #252

rbkumar88 opened this issue Aug 6, 2019 · 2 comments

Comments

@rbkumar88
Copy link

Is this behaviour expected? If so how to negate that.


import (
	"fmt"
	"github.com/pquerna/ffjson/ffjson"
)

func main() {
	level:=&Level{Label:"<<< GET"}
	testFfjson(level)
}
type Level struct {
	Label      string
}
func testFfjson(m interface{}) {
	b,err:= ffjson.Marshal(&m)
	if err!=nil{
		fmt.Printf("error in ffjson marshal for %v : %v",m,err)
		return 
	}
	fmt.Printf("%s\n", b)
}

Output:

{"Label":"\u003c\u003c\u003c GET"}

@erikdubbelboer
Copy link
Contributor

Yes this is expected. This is exactly the same as with the encoding/json package: https://play.golang.org/p/IHXPJmjh_bM
Both packages do this because it's perfectly valid JSON and JSON is mostly used inside a web context where < might cause issues with HTML tags.

And just like with encoding/json you can use the Encoder.SetEscapeHTML(false) to turn this off: https://play.golang.org/p/1sGNH1ae6zm

@pquerna pquerna closed this as completed Aug 13, 2019
@pquerna
Copy link
Owner

pquerna commented Aug 13, 2019

@erikdubbelboer Thank you for explaining!

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

3 participants