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

🚀 Add ctx.PureJSON() to response json without HTML escape #690

Closed
david7482 opened this issue Jul 30, 2020 · 1 comment
Closed

🚀 Add ctx.PureJSON() to response json without HTML escape #690

david7482 opened this issue Jul 30, 2020 · 1 comment

Comments

@david7482
Copy link

david7482 commented Jul 30, 2020

Is your feature request related to a problem?
By using ctx.JSON(), it would always do HTML escape because it's the default behavior of json.Marshal().

app.Get("/json", func(c *fiber.Ctx) {
	c.Status(fiber.StatusOK).JSON(map[string]string{
		"message": "<foo> hello&",
	})
})
$ curl localhost:8080/json
{"message":"\u003cfoo\u003e hello\u0026"}

Describe the solution you'd like
Add a new function which would use a custom json encoder by SetEscapeHTML(false).
gin's implementation

Currently, I need to implement this in app side then set the body manually.

I would love to support this PR if you want to add this feature.
Thanks

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

No branches or pull requests

2 participants