Set does not have the same meaning as Array. A collection is a collection of unique elements, and an array is an ordered collection of elements that are not necessarily unique.
To load JSON into a map instead of an associative array, see JSON.parse . You can write a custom resolver, for example:
JSON.parse(json, (k, v) => {
if(typeof v == 'object' && !(v instanceof Array))
return new Map(Object.entries(v));
return v;
});
Map , Object.entries. Object.entries - , . :
Object.entries = function* entries(obj) {
for (let key of Object.keys(obj)) {
yield [key, obj[key]];
}
}
( Object.prototype.entries, .)