Answer the question
In order to leave comments, you need to log in
Random selection of ID from JSON?
I have a JSON, I need to extract a random id from it, and of course the value in it.
How can I do that?
[
{
"id": 124124,
"firstname": "Районный",
"lastname": "Прокурор",
"warns": 0,
"role": 11,
"flip": 0,
"rank": "Участник",
"ban": false,
"isBanned": "Нет",
"tempban": 0,
"mute": 0,
"mutesleft": 0,
"violations": 0,
"botmute": 0,
"nick": "хай"
},
{
"id": 123123,
"firstname": "Кто",
"lastname": "Никто",
"warns": 0,
"role": 11,
"flip": 0,
"rank": "Участник",
"ban": false,
"isBanned": "Нет",
"tempban": 0,
"mute": 0,
"mutesleft": 0,
"violations": 0,
"botmute": 0
"nick": "пока"
},
{
"id": 125125,
"firstname": "Крутой",
"lastname": "Поц",
"warns": 0,
"role": 1,
"flip": 0,
"rank": "Участник",
"ban": false,
"isBanned": "Нет",
"tempban": 0,
"mute": 0,
"mutesleft": 0,
"violations": 0
"nick": "привет"
}
]
Answer the question
In order to leave comments, you need to log in
const item = items[Math.floor(Math.random() * items.length)];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question