1
00:00:01,450 --> 00:00:08,500
In this lesson, we're going to be looking at Jason Passe and Jason Stringer Thig and Storify is not

2
00:00:08,500 --> 00:00:14,350
only fun to say, but it is super useful whenever you want to turn an object into a string and you can

3
00:00:14,350 --> 00:00:17,810
use pass to turn it back into a usable object format.

4
00:00:18,130 --> 00:00:23,970
Got a few examples as well as we'll take a closer look at what Mozilla Developer Network has as an example.

5
00:00:24,190 --> 00:00:30,250
So they've got a typical object here and notice that this is within a string format and when we pass

6
00:00:30,250 --> 00:00:33,730
it into JSON, then we have access to the object.

7
00:00:33,910 --> 00:00:37,360
So run that and we see that we've got count.

8
00:00:37,540 --> 00:00:42,310
So instead of having it within the string, it turns it into a usable object format and then you can

9
00:00:42,310 --> 00:00:47,620
manipulate the values and the other way, going the other way around, of course, is String Afie so

10
00:00:47,620 --> 00:00:54,180
converts a JavaScript object or a value to a JSON string, so string OWFI.

11
00:00:54,430 --> 00:00:56,170
So we're stratifying an object.

12
00:00:56,200 --> 00:01:03,310
So basically it's turning it into a string where stratifying an array and string value boolean values

13
00:01:03,310 --> 00:01:11,320
or turning them all into a usable format within the array as well as stratifying undefined function

14
00:01:11,530 --> 00:01:12,710
with blank function.

15
00:01:12,730 --> 00:01:14,530
So these are all coming back as null.

16
00:01:14,740 --> 00:01:16,510
So that's something to note that as well.

17
00:01:16,630 --> 00:01:18,640
Symbol function and undefined.

18
00:01:18,850 --> 00:01:21,710
When you string Afie them, they come back as null.

19
00:01:22,030 --> 00:01:27,460
So instead of coming back as undefined function because when you string a it, of course it has to be

20
00:01:27,460 --> 00:01:32,140
within a string format and you can't have a function that's sitting within a string format.

21
00:01:32,150 --> 00:01:33,460
So that's where it just comes back as.

22
00:01:34,270 --> 00:01:36,550
Also if you string if I added object.

23
00:01:37,060 --> 00:01:39,040
So a date is also an object.

24
00:01:39,220 --> 00:01:44,380
And when you string a fight, you get this type of output being created so you can run.

25
00:01:44,380 --> 00:01:49,600
And you see you've got the double quotes around there because it already is a coded string around that

26
00:01:49,600 --> 00:01:52,050
object and that's how it was being written.

27
00:01:52,060 --> 00:01:53,680
So we saw that within the last lessem.

28
00:01:53,770 --> 00:02:01,090
So of course, we do have a challenge for you within this lesson, and that is to take an object, convert

29
00:02:01,090 --> 00:02:07,600
it into a string output, into the console as a string, and then take that same object that was turned

30
00:02:07,600 --> 00:02:13,800
into a string and turn it back into an object and output the values.

31
00:02:13,800 --> 00:02:19,720
So for first and last name, really simple object where we've got first and last and turning into a

32
00:02:19,720 --> 00:02:25,530
string and then parsing it back into an object and then outputting the values within the object format.

33
00:02:25,780 --> 00:02:26,860
So go ahead and try this out.

34
00:02:26,860 --> 00:02:29,940
You can pause the video and I'll walk you through the solution for this one.

35
00:02:30,310 --> 00:02:31,600
It's opening up the ED.

36
00:02:31,720 --> 00:02:37,240
First, let's create the object and you can contain whatever information you want within this object.

37
00:02:37,510 --> 00:02:42,700
In this case, I'm going to just use the first and last creating really simple.

38
00:02:43,060 --> 00:02:48,970
So that means that if I go into my object, I can see that it's within an object format.

39
00:02:49,120 --> 00:02:56,380
And if I wanted to get back first, I can get Lowrance back this way and I can also get back lost because

40
00:02:56,380 --> 00:02:59,110
of course it is an object so it can output those values.

41
00:02:59,650 --> 00:03:07,180
So the objective of this exercise was to try this and convert it first into a string to create a string

42
00:03:07,210 --> 00:03:09,480
and using JSON string a fine.

43
00:03:09,520 --> 00:03:15,040
And then we need to pass the object that we want to string and console log out just to make sure that

44
00:03:15,040 --> 00:03:15,850
it is a string.

45
00:03:15,850 --> 00:03:16,780
So no tricks here.

46
00:03:17,170 --> 00:03:22,630
We see that now this object has been turned into a string and you can't really do a whole lot with it.

47
00:03:22,870 --> 00:03:25,720
You've got no option for first or anything like that.

48
00:03:25,720 --> 00:03:28,840
It just comes back undefined because it's a string, it's not an object.

49
00:03:29,620 --> 00:03:34,720
So we want to turn it back into a new object or back into an object.

50
00:03:35,080 --> 00:03:41,620
And this is where we can use JSON pass and taking the my string, we're going to pass it back into an

51
00:03:41,620 --> 00:03:45,100
object format and then using the console.

52
00:03:45,370 --> 00:03:52,650
Let's output the new object and we're going to get first and console log output, the new object, and

53
00:03:52,660 --> 00:03:53,950
we'll get the value for lost.

54
00:03:54,760 --> 00:03:59,500
So when we refresh, we see we got all of those values being output so we can use it again.

55
00:03:59,980 --> 00:04:07,330
And this is really useful, especially when you need to save data or within the browser as a string

56
00:04:07,510 --> 00:04:10,760
and then convert it back into an object to make use of it within your code.

57
00:04:10,780 --> 00:04:12,610
A lot of examples of this to try to.
