Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
es6 Map to Json
const mapToObject = (map) => {
const out = Object.create(null);
map.forEach((value, key) => {
if (value instanceof Map) {
out[key] = mapToObject(value);
}
else {
out[key] = value
}
});
return out;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment