Good evening,
I'm facing a simple problem in JSON. I'm developping a smartwatch (Pebble) app which gets data from an API, which returns the following :
{
"name": "toto",
"count": 55,
"results": {
"collection1": [
{
"article": "Content number 1"
},
{
"article": "Content number 2"
},
{
"article": "Content number 3"
}
]
}
}
The problem is the following : is it possible to access only the latest "article" content from this JSON ? So in this case, it would be "Content number 3".
Here is what I've got so far, but it returns only the 1st element :
ajax({ url: 'MY_API_URL', type:'json' }, function(data){
simply.vibe(); // Vibrate the watch
var message = data.results.collection1[0].article;
simply.body(message); // display the message on the watch
Thanks a lot !