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

Comments

Projects
None yet
3 participants
@gopherbot
Copy link

commented Sep 14, 2013

by runner.mei:

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

This comment has been minimized.

Copy link
Contributor

commented Sep 16, 2013

Comment 1:

What would the functions do?
@rsc

This comment has been minimized.

Copy link
Contributor

commented Sep 16, 2013

Comment 2:

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

This comment has been minimized.

Copy link
Author

commented Sep 17, 2013

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

This comment has been minimized.

Copy link
Contributor

commented Oct 18, 2013

Comment 4:

You can use json.Marshal instead of JSEscapeString here.

Status changed to WorkingAsIntended.

@gopherbot

This comment has been minimized.

Copy link
Author

commented Oct 24, 2013

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.
You can’t perform that action at this time.