I have having trouble parsing out the similar videos title. There will always be either 1 or 2 similar movies in the json so I am trying to store both of those videos in two separate arrays.
Here is my JSON example here:
{
"status": "ok",
"status_message": "Query was successful",
"data": {
"limit": 20,
"movies": [
{
"id": 400,
"url": "www.google.com",
"title": "Battle for Skyark",
"year": 2016,
"rating": 2.8,
"runtime": 88,
"genres": [
"Action",
"Adventure",
"Family",
"Sci-Fi"
],
"summary": "When a mysterious race of creatures takes over a desolate Earth, humanity must take refuge in SkyArk, the city in the sky. After the rebellion against a corrupt leadership fails, the wealthy doom the rebels' children to live on the ruins of the old Earth. The rebel leader's son, Rags, must lead his fellow exiles against the monsters in order to have a chance to return to SkyArk, but he soon finds that he has a much greater purpose in saving humanity.",
"language": "English",
"background_image": "background.jpg",
"state": "ok",
"similarvideos": [
{
"title": "The Long Road"
},
{
"title": "Boyhood"
}
],
"date_uploaded": "2015-10-31 21:48:19",
"date_uploaded_unix": 1446342499
}
}
}
I am able to to parse out summaries like this (along with other elements):
var summarys = [String]()
self.summarys = json.valueForKeyPath("data.movies.summary") as! [String]
This is how I am trying to parse the similar videos title and it is not working:
self.similarfirstmovies = json.valueForKeyPath("data.movies.similarvideos[0].title") as! [String]
self.similarsecondmovies = json.valueForKeyPath("data.movies.similarvideos[1].title") as! [String]
All help is much appreciated.