Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 387 Bytes

map_json.md

File metadata and controls

18 lines (13 loc) · 387 Bytes

Map to JSON / JSON to Map

convert Map to JSON

const someMap = new Map();
someMap.set('key', 'value');

const jsonFromMap = Object.fromEntries(someMap);

// { "key": "value" }

read JSON and convert to Map

const path = require('path')

const someMap = Object.entries(JSON.parse(await fs.promise.readFile(path.resolve(jsonPath)).toString()));