I have an string from backend source, of format:
numbers: "1123763449056714753, 1123764853364097024, 1123770213739241473..."
I want to convert it into key-value pair something form so that I can map over these ids for my individual item div:
["numbers": [
{"id":1123763449056714753 },
{"id":1123764853364097024 },
{"id":1123770213739241473 },
....
]
]
or
[ {"id":1123763449056714753 },
{"id":1123764853364097024 },
{"id":1123770213739241473 },
....
]
I tried using forEach()/ map() but gets error as undefined. Also I am not sure whether it is a collection of string or array of strings Please help
let obj = JSON.parse('{' +str+'}'); obj.numbers = obj.numbers.split(',').map(id => ({id}))object.numbers = object.numbers.split(',').map(i => { id: +i }. The question is quite unclear and doesn't hold the minimal amount of informations needed to verify the example. Please clarify it and add what you've tried.idis of type number. All these numbers are bigger thanNumber.MAX_SAFE_INTEGER. So, when string converted to number, they won't be the same numbers anymore