0 1 00:00:00,610 --> 00:00:06,910 So in the last lesson, we manage to figure out how to use Alamofire to make a HTTP GET request and grab 1 2 00:00:06,940 --> 00:00:09,650 a whole bunch of information from Wikipedia. 2 3 00:00:09,670 --> 00:00:16,030 Now, in this lesson, we're going to pass that information and display it inside our app in a label, like 3 4 00:00:16,030 --> 00:00:16,440 so. 4 5 00:00:16,570 --> 00:00:21,430 So we've done this before in both Clima and FlashChat, so I want to set it as a challenge and see if 5 6 00:00:21,430 --> 00:00:28,210 you can turn this response into a JSON, and then parse that JSON in order to grab the relevant extract, and 6 7 00:00:28,210 --> 00:00:29,540 put it into a label. 7 8 00:00:29,560 --> 00:00:31,830 It might involve a little bit of design work as well. 8 9 00:00:31,870 --> 00:00:32,530 Here's a hint 9 10 00:00:32,530 --> 00:00:37,450 before you start working on the challenge. When we printed this response in the last lesson, the data 10 11 00:00:37,450 --> 00:00:41,490 type of that response is a DataResponse object. 11 12 00:00:41,500 --> 00:00:47,320 Now, that is not same as a JSON, and you want to be able to use something like Jason editor online to 12 13 00:00:47,310 --> 00:00:51,190 be able to visualize the JSON structure more easily. 13 14 00:00:51,190 --> 00:00:57,630 So in order to turn it into a JSON, remember, we need to use the SwiftyJSON framework. So we can write 14 15 00:00:57,670 --> 00:00:58,570 JSON, 15 16 00:00:58,870 --> 00:01:05,350 and then we can convert that response.result.value into a JSON value. 16 17 00:01:05,350 --> 00:01:09,360 So let me show you side by side the differences. If you have a look over here, 17 18 00:01:09,370 --> 00:01:16,000 this is our Data Response Object, and on the right is the same thing that's been converted into a JSON. 18 19 00:01:16,010 --> 00:01:21,610 You can see that in the JSON structure, all the keys are Strings, and they have quotation marks around 19 20 00:01:21,610 --> 00:01:25,440 them, whereas in the object, the keys are simply as they are. 20 21 00:01:25,660 --> 00:01:32,650 Now, if you tried to put this Data Response Object into the JSON editor straight away, you can see 21 22 00:01:32,650 --> 00:01:36,820 that it's going to give you a whole bunch of errors, and it won't be able to parse it because this is 22 23 00:01:36,820 --> 00:01:42,520 not JSON. But after you've converted it, then it will be able to parse it without any problems. 23 24 00:01:42,520 --> 00:01:48,820 And the idea is that you want to use this structure to guide your JSON parsing. 24 25 00:01:48,820 --> 00:01:54,160 So if you don't remember how we parsed JSON using SwiftyJSON, then have a look back at CLIMA or at 25 26 00:01:54,160 --> 00:01:59,200 FlashChat and remind yourself how he managed to chain keys together in order to get to the thing that 26 27 00:01:59,200 --> 00:02:02,180 we want which is, of course, this extract over here. 27 28 00:02:02,230 --> 00:02:05,620 So I'm going to set this as a challenge, give it a go, and see if you can do it. 28 29 00:02:05,620 --> 00:02:09,410 Don't worry if you can't, I'm going to walk you through the solution in the next lesson.