How do I JSON.stringify( anObject ) without colons, backslashes, curly braces or quotes?

1.4k views Asked by At

This is a simple sentence. I don't want anything <form><b>but</b></form> this.

But after some client-side html manipulation and...

var newBody = JSON.stringify(req.body);

followed by an update to MongoDb,

var update = { '$set' :{ 'body' : newBody} } 

I have this:

body: '{"This is a simple sentence. I don\'t want anything <form><b>but</b></form> this. ":""}' 

And when I convert it back to html it has curley braces and quotes, which exacerbate with each update. I looked here, and have tried escape back-slashes, but I can't figure it out. Thank you.

{"{\"This is a simple sentence. I <form><b>don't</b></form> want this. \":\"\"}"}
1

There are 1 answers

1
actual_kangaroo On BEST ANSWER

I believe JSON.stringify is unncessary, assuming you passed post parameters simpleSentance= 'I dont want anything <b>but</b> this'

var newBody = req.body.simpleSentance