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.

EDIT
It 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.

Leave a Comment