This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if let array = json as? [Any] { | |
for object in array { | |
print(object) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JSON - | |
[[{"Title":"testi27","Original filename":"rainforest.mp3","Description":"joo","Tags":"testi\r\n\u00e4\u00e4ni\r\njoo","Category":"","Sound Type":"soundscapes","Creation date":"2016-10-27 12:20:42","File extension":"mp3","File size(KB)":"154.8","Created by":"podcast","Collection name":"ylepodcast","Collection ID":"5","Download link":"http:lii.fi"}],[{"Title":"Adrenaline","Original filename":"Adrenaline.mp3","Description":"there goes descriptions","Tags":"Category:Music\r\nMusic","Category":"","Sound Type":"soundscapes","Location - longitude":"www.imgur.com","Length (sec)":"132","Creation date":"2016-10-27 13:29:28","File extension":"mp3","File size(KB)":"5301.0","Created by":"podcast","Collection name":"Testi","Collection ID":"17","Download link":"http:lii.fi"}]] | |
Swift - | |
Alamofire.request("link_to_json/", method: .get, parameters:parameters) | |
.responseJSON{response in | |
if let json = response.result.value { | |
if let array = json as? [Any] { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PodcastTableViewController: UITableViewController, DataParserObserver { | |
var podcasts = [Podcast]() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.podcasts = [Podcast]() | |
let dataParser = HttpRequesting() | |
dataParser.httpGetPodCasts(parserObserver: self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func httpGetApi () { | |
let parameters: Parameters = ["username": "username", "password": "password"] | |
Alamofire.request("url", method: .post, parameters:parameters, encoding: JSONEncoding.default) | |
.responseJSON{response in | |
if let json = response.result.value as? [String: String] { | |
self.setApiKey(apiKey: json["api_key"]!) | |
}else{ | |
self.setMessage(statusMessage: "Ei toimi") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func httpGetApi () { | |
let parameters: Parameters = ["username": "username", "password": "password"] | |
Alamofire.request("addr", method: .post, parameters:parameters, encoding: JSONEncoding.default) | |
.responseJSON{response in | |
if let json = response.result.value as? [String: String] { | |
self.setApiKey(apiKey: json["api_key"]!) | |
}else{ | |
self.setMessage(statusMessage: "Ei toimi") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PodcastTableViewController: UITableViewController, DataParserObserver { | |
var podcasts = [Podcast]() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.podcasts = [Podcast]() | |
let dataParser = HttpRequesting() | |
dataParser.httpGetPodCasts(parserObserver: self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PodcastTableViewController.swift | |
class PodcastTableViewController: UITableViewController, DataParserObserver { | |
var podcasts = [Podcast]() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.podcasts = [Podcast]() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have two arrays, questions and answers. I need to merge them together so in question there are its answer if it have answer. | |
This is how it should look like: | |
array(‘questions’ => | |
array(‘id’=> 1, | |
’question’ => ‘How sick you are’, | |
‘answer’ => 3)) | |
And if there are no answer it should only show the question. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for($i=0;$i<count($kysymykset);$i++){ | |
if(count($vastaukset) > 0){ | |
foreach($vastaukset as $key){ | |
if ($kysymykset[$i]['TherapygroupQuestions']['id'] == $key['TherapygroupAnswers']['question_id']) { | |
$kysymykset_vastaukset[$i] = array_merge($kysymykset[$i]['TherapygroupQuestions'], array('vastaus' => $key['TherapygroupAnswers']['vastaus'], 'vastaus_id' => $key['TherapygroupAnswers']['id'])); | |
} | |
} | |
}else{ | |
$kysymykset_vastaukset[$i] = array_merge($kysymykset[$i]['TherapygroupQuestions']); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$questions = array('TherapygroupQuestions' => | |
array('id' => 1,'question' => "How much this hurt?"), | |
array('id' => 2, 'question' => "How much your feet hurt?"), | |
array('id' => 3, 'question' => "How much your hand hurt?") | |
); | |
$answers = array('TherapygroupAnswers' => | |
array('id' => 3, 'question_id' => 1, 'answer' => 1), | |
array('id' => 5, 'question_id' => 3, 'answer' => 5) | |
); |
OlderNewer