Skip to content

Instantly share code, notes, and snippets.

@artemsky
Created April 6, 2017 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artemsky/a3be78ec43ac698226b7661e28e354fd to your computer and use it in GitHub Desktop.
Save artemsky/a3be78ec43ac698226b7661e28e354fd to your computer and use it in GitHub Desktop.
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