I hope this function is self-explanatory enough. This is what I used to do the job.
/*
* Turn the map to an Object so it can be converted to JSON
*/
function mapToObj(inputMap) {
let obj = {};
inputMap.forEach(function(value, key){
obj[key] = value
});
return obj;
}
JSON.stringify(returnedObject)