I'm trying to convert JSON of the form:
{1: 1, 4: -1}
to a Map
where the keys are of type integer.
I managed to do this:
let myMap = new Map(Object.entries(payload));
but it ends up converting the keys to strings.
What am I doing wrong?
Object.entries
, it means its anObject
JSON.parse
if so you can use thereviver
option.