I am facing an issue with the JSON structure for the data I should pass to the server. Below is the required format.
var data = '{"listingHotspots": [{"PropertyGuid": "5dc934f6-cb5a-44d4-95e6-cf7d5712359e","Hotspot": {"Coordinates": "581,391,676,391,677,410,714,410,715,562,599,562,598,527,597,473,597,409,580,407,581,391"}}]}'
My code is
var data = {'listingHotspots':[]};
data['listingHotspots'].push({'PropertyGuid':savedGuid,'Hotspot': {'Coordinates':coord_string}});
This is creating a valid JavaScript object but not the one i need. I also used JSON.stringify() but it resulted in a Undefined value. Any help would be greatly appreciated.
JSON.stringify() may not be in the target browser. If that’s the case, you’ll need to load json2.js. json2.js won’t clobber the native JSON.stringify() if it exists, so aside from the extra request, no harm loading it all the time. See http://www.json.org/js.html and http://www.cdnjs.com/#/search/json2 and http://modernizr.com/docs/#load