Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

convert map to json js, map to json

const mapToJson = (map) => JSON.stringify(Object.fromEntries(map));
const map = new Map([
  ['user1', 'John'],
  ['user2', 'Kate'],
  ['user3', 'Peter'],
]);
const json = mapToJson(map);
// {"user1":"John","user2":"Kate","user3":"Peter"}
console.log(json);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #map #json #map #json
ADD COMMENT
Topic
Name
4+8 =