How can I emulate php's json_encode in javascript / node js using JSON.stringify? -


I'm looking for a way to copy php json_encode behavior from node js, showing an example here What does PSP do with a URL that is in the object that is json_encoded:

    

Generates the following output:

  {"url": "http: \ / \ example.com \ / note \ / \" / Slashes \ / get \ / backslashed "}   

Using the Js and JSON.stringify function here:

  var foo = new object ( ); Foo.url = "http://example.com/note/that/the/slashes/do/not/get/backslashed" console.log (JSON.stringify (foo));   

I see this output instead:

  {"url": "http://example.com/note/that/the/slashes/do/ / No / Received / Backslassed "}   

Do you know how to get JSON in a clean way. Is it behaving in the same way that PHP behaves?

Additional information: I know that these slashes are not necessary for correct JSN encoding, but I have a remote server I'm sending a Jason encoded object on which I do not have control and I do not like it without backslash. / P>

More info: And I tried to put my own backslabs and then called JSON. Strevette but JSON attempts to avoid backslaces correctly, so I ended up with \ \ / / instead of \ / which I wanted.

If this is the only slash, then you / to \ / After conversion

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -