Issue with JSON.stringify adding a extra \ and "" to my Json object Issue with JSON.stringify adding a extra \ and "" to my Json object arrays arrays

Issue with JSON.stringify adding a extra \ and "" to my Json object


It looks like you are placing a string as the value in your map. You should do something like:

var objMap = {"JObject" : ValuesArray};var json = JSON.stringify(objMap)

What's happening is you are double json encoding your values array - note that your "invalid" JSON value is actually a JSON string rather than the array that you want.

EDITIt looks like you are sticking in JSON strings of maps into an Array and then stringifying that. Here's a jsfiddle that should help you get what you are looking for - http://jsfiddle.net/4G5nF/

In your post request, try this

var jObject = {"JObject" : ValuesArray};$.ajax({   url: address,           type: 'POST',           dataType: 'json',           data: jObject,           success: function (data)  { .. }});

Note the change in the data attribute. That is a value that is automatically JSONified for you.


const config = {a: 1, b: 2}console.log(JSON.stringify(JSON.stringify(config)))

"{\"a\": 1, \"b\": 2}"


May be you have an old prototype library. As I remove it, bug has disappeared