• 7 Posts
  • 14 Comments
Joined 1 year ago
cake
Cake day: June 11th, 2023

help-circle





  • Where would/should the mapping happen? Probably not the Set constructor. JSON.parseSet()?

    JSON.parseSet = json => new Set(JSON.parse(json));
    JSON.parseSet('["A", "B", "C", "A", "B"]'); // Set(3) [ "A", "B", "C" ]
    

    /edit: JSON.parseMap()

    JSON.parseMap = json => new Map(Object.entries(JSON.parse(json)));
    JSON.parseMap('{"a":1,"b": 2}'); // Map { a → 1, b → 2 }