Hello Can you help me to filter such Json Object:
{
"data": {
"statuses": [{
"entities": {
"urls": [],
"user_mentions": [{
"screen_name": "name1"
}]
},
"entities": {
"urls": [],
"user_mentions": [{
"screen_name": "name2"
}]
},
"entities": {
"urls": [],
"user_mentions": [{
"screen_name": "name3"
}]
}
}]
}
}
I need to get array with values of each key screen_name.
For example: array = ["name1","name2","name3"]
How i can do it without frameworks with only JS?
Thanks for your help. I have updated Json to such like this:
var obj = {
"data": {
"statuses": [{
"urls": [],
"user_mentions": [{
"indices": [
3,
16
],
"id_str": "626444770",
"id": 626444770,
"name": "katheryn",
"screen_name": "sella_sandra"
}, {
"indices": [
"***",
"***"
],
"id_str": "21447363",
"id": 21447363,
"name": "KATY PERRY",
"screen_name": "katyperry"
}, {
"indices": [
"***",
"***"
],
"id_str": "21447363",
"id": 21447363,
"name": "KATY PERRY",
"screen_name": "floyd"
}]
}]
}
I'm wanna to get array of screen_names.I wrote such code.But when i use for.It doesn't work here:
console.log (statuses[0].user_mentions[i].screen_name)
I't silly mistake but I cannot find out how correct that. Help guys!
var statuses = obj.data.statuses;
for (var i=0; i<statuses.length; i++ )
{ if ( typeof statuses[0].user_mentions !== "undefined")
{
for (var i=0; i<statuses.length; i++){
console.log (statuses[0].user_mentions[i].screen_name);
}
}
else console.log ="No senders";
}
statusesstill makes no sense."statuses":[{"entities": {...}, "entities": {...}, "entities": {...}}]