Skip to content

Instantly share code, notes, and snippets.

@ToJen
Created March 23, 2018 17:50
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 ToJen/db252305bcf6b2eb6b0a7c36305e87e9 to your computer and use it in GitHub Desktop.
Save ToJen/db252305bcf6b2eb6b0a7c36305e87e9 to your computer and use it in GitHub Desktop.
function mapToJson(map) {
return JSON.stringify([...map]);
}
function jsonToMap(jsonStr) {
return new Map(JSON.parse(jsonStr));
}
// map to JSON
const obj = [...enemyMap].reduce((o, [key, value]) => (o[key] = value, o), {});
[...obj]
JSON.parse(JSON.stringify(obj[1])) // should be done in a loop
// JSON to map
// test APIs
curl -i -X POST -H "Content-Type: application/json" -d '{}' localhost:4000/pingland/create-level
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment