I have suggestion about specification of the escape.

# Renan Bastos (6 years ago)

Hello,

Guys, I have thinked about one this title. So, I suggestion to we change the form of to escape one Object JSON. Today we have that to make this converting JSON to String, but I thought more interesting the function native did it. What you think about?

Att, See ya. @renanbastos93 www.renanbastos.com.br

# Michael Rosefield (6 years ago)

I think I can speak for the rest of us when I say: I really am not sure what you're trying to say, here. Could you provide some examples?

# Renan Bastos (6 years ago)

Hey guys,

I communicate that when we go use the escape to object JSON it don't escape correctly. So I think we should add this suggestion.

const obj2 = {"name": "NodeJS", "version": "all"}; console.log(escape(obj)); //%5Bobject%20Object%5D

It needs to do this:

const obj = {"name": "NodeJS", "version": "all"}; console.log(escape(obj)); //%7B%22name%22%3A%22NodeJS%22%2C%22version%22%3A%22all%22%7D

As this we will reduce a step to escape.

Wthat's you think about? I make myself available to do this.

Now gotcha?

2017-11-24 7:52 GMT-02:00 Michael Rosefield <rosyatrandom at gmail.com>:

# T.J. Crowder (6 years ago)

On Fri, Nov 24, 2017 at 11:38 AM, Renan Bastos <renanbastos.tec at gmail.com>

wrote:

Hey guys,

I communicate that when we go use the escape to object JSON it don't escape correctly. So I think we should add this suggestion.

const obj2 = {"name": "NodeJS", "version": "all"}; console.log(escape(obj)); //%5Bobject%20Object%5D

I don't see any need to do that. escape(JSON.stringify(obj)) is not over-long. Small, composable functions are a good thing. And if you want to define a escapeAsJSON function, it's easy to do that in your code.

I do see reasons not to do it: We'd have to handle the situation where an object overrides toString and is expecting the string from that, not JSON, to be used by escape(obj). Handling that would be ugly, it would be along the lines of "Get toString from the object. If toString is not %ObjProto_toString%, then..."

-- T.J. Crowder

# Michał Wadas (6 years ago)

It would break backwards compatibility, so it's absolute no-go.

Adding new function with such behaviour is unlikely, because escape is defined in Annex B - and Annex B is effectively "deprecated but needs to be there for backwards compatibility". "Use encodeURI developer.mozilla.org/pl/docs/Web/JavaScript/Referencje/Obiekty/encodeURI

or encodeURIComponent developer.mozilla.org/pl/docs/Web/JavaScript/Referencje/Obiekty/encodeURIComponent

instead" (MDN).

And I agree with T.J. Crowder - it's easily implementable in user land as single-line arrow function and it's very specific use case.

# Renan Bastos (6 years ago)

Thanks guys.

2017-11-24 10:20 GMT-02:00 Michał Wadas <michalwadas at gmail.com>: