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

encoding/json: can add JSEscape adn JSEscapeString function #6385

Closed
gopherbot opened this issue Sep 14, 2013 · 5 comments
Closed

encoding/json: can add JSEscape adn JSEscapeString function #6385

gopherbot opened this issue Sep 14, 2013 · 5 comments

Comments

@gopherbot
Copy link

by runner.mei:

func JSEscape(dst io.Writer, src []byte)
func JSEscapeString(dst io.Writer, src string)
@adg
Copy link
Contributor

adg commented Sep 16, 2013

Comment 1:

What would the functions do?

@rsc
Copy link
Contributor

rsc commented Sep 16, 2013

Comment 2:

More importantly, what would they do that json.Marshal does not?

@gopherbot
Copy link
Author

Comment 3 by runner.mei:

This is in the interests of efficiency, the scene is as follows:
buffer.WriteString(`{"a":"`)
JSEscapeString(buffer,`aa"a`)
buffer.WriteString(`", "b":"`)
JSEscapeString(buffer,`aa"a`)
buffer.WriteString(`"}`)

@rsc
Copy link
Contributor

rsc commented Oct 18, 2013

Comment 4:

You can use json.Marshal instead of JSEscapeString here.

Status changed to WorkingAsIntended.

@gopherbot
Copy link
Author

Comment 5 by runner.mei:

yes,it is ok, but it is slower with unnecessary memory copy

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants