Answer the question
In order to leave comments, you need to log in
How to extract three JSON branches?
Hello. Small question:
I have this JSON response:
{
"response": {
"count": 398,
"items": [{
"id": 1680163,
"body": "test message",
"user_id": 2314852,
"from_id": 2314852,
"date": 1468343751,
"read_state": 1,
"out": 0
}],
"in_read": 1680163,
"out_read": 1680162
}
}
count
etc., but there are small problems: id
, but when I try, an error occurs or undefined
, below are examples of my extractions: message.send(`${response.count}`);
message.send(`${response.items.id}`);
undefined
cmd.hear(/^(?:бс инфо)$/i, async (message, bot) => {
if(!message.isChat) return bot(`команда работает только в беседе!`);
await vk.api.messages.getConversationMembers({
offset: 0,
count: 1,
peer_id: message.peerId,
start_message_id: 0,
group_id: 184895474
}).then((response) => {
message.send(`${response.items["body"]}`);
});
});
Answer the question
In order to leave comments, you need to log in
response.items[0].id
you have items - an array that already contains an object with an id field
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question