I have this data.json file and I need to get the values of the "hashtags" it is 10,000 json datas in my file so I include only the important one..
var data =
[
{
"favorite_count": 0,
"entities": {
"hashtags": [
{
"text": "Hope",
"indices": [
0,
5
]
},
{
"text": "USA",
"indices": [
6,
10
]
},
{
"text": "Youth",
"indices": [
11,
17
]
},
{
"text": "sex",
"indices": [
51,
55
]
},
{
"text": "condoms",
"indices": [
94,
102
]
},
{
"text": "STD",
"indices": [
120,
124
]
},
{
"text": "HPV",
"indices": [
135,
139
]
}
]
}
},
{
"favorite_count": 0,
"entities": {
"hashtags": [
{
"text": "starbucks",
"indices": [
3,
13
]
}
]
}
}
]
So I have here a hashtags which I want to get ONLY the text and if it is a null it will not get anything.. I can't get the values and I don't know how to iterate it because I am not familiar in json.. here is my code by the way in javascript
$(document).ready(function()
{
$("#hashtagBtn").click(function()
{
$("#theTweets").html(graphHashtag());
});
});
function graphHashtag()
{
var getHashtags = [];
$.each(data, function(i, obj)
{
if(obj.hasOwnProperty("text") && data[i].lang == "en" && data[i].entities.hashtags != null)
getHashtags.push(obj.entities.hashtags[i].text);
});
return getHashtags;
}
JSON.parse(data).