Using JSON.stringify on Javascript object inserts backslashes Using JSON.stringify on Javascript object inserts backslashes mongoose mongoose

Using JSON.stringify on Javascript object inserts backslashes


This is mongoose related issue, try this first: click (read the comments). Or if you don't want to read:

JSON.stringify(obj.toObject({minimize:false}));

What I wanted to point out in your code is one thing though:

Instead of:

var value1="1"var value2="2"

do this:

var value1 = 1,    value2 = 2;

When you put numbers between the quotes they are treated as strings and this can give you a lot of trouble. value1 + value2 in the first scenario will give you 12 ("foo" + "bar" = foobar), meanwhile expected output is 3, which you obtain defining variables as numbers (second case).