Well, we have a huge day ahead.
Welcome to week one.
Day four.
This is the day.
It's the second yellow day of digging into integrations.
But in addition we're also going to talk about data.
And we're going to look at expressions at least at a high level.
Let's get into it.
So largely in NHSN, data is something which is described using this format called JSON.
And I imagine that at least half of you, you may fall into the half that are very familiar with JSON.
You've possibly some of you have just seen it before a lot.
Some of you actually probably JavaScript people that know it back to front, and some of you may be
new to it.
You've probably seen it, but you may not know that much about it.
I'm going to cover it briefly.
The main message is you will get very familiar with this.
You're going to see it a lot.
JSON is this very simple, standard way to describe structured data in a way that happens to also be
sort of human readable, which is very convenient.
So machines understand it, humans understand it, and we can work together with it.
Let's cover the four basic ingredients of JSON.
And if you know all this already, just put me on two x axes.
Zoom through this.
So first up, Jason is a way of describing data.
Fundamentally, it expresses things as key value pairs, which means that everything has a name and
a value.
The pair could be a person might have a first name and a value, a last name and a value, an age and
a value.
These are examples of key value pairs, and that forms the heart of Jason and these values.
They can be bunches of text which are called strings.
They can be numbers.
They can be booleans which means like true or false.
And it can be a few other things as well.
So the second key ingredient of Jason is called an object.
An object is basically a bunch of key value pairs.
It's a ton of them.
There could be a person object, which means there might be a first name, last name, age, and other
things.
There's another name they're sometimes called dictionaries and dictionary will be familiar to people
from a Python background because it's like a Python dictionary.
Uh, so that is known as an object, a bunch of key value pairs, or maybe a bit more, as we will see.
And the next ingredient is called an array, Ray, which just means an ordered list of things.
And then the final one nesting.
This is to say that a JSON object we've already said it can contain strings and numbers and booleans.
It could also contain other JSON objects, and those JSON objects could also contain objects and lists
of objects.
So you could have some JSON object that is composed of lots of other objects, which themselves are
composed of more objects.
And a lot of this will come together when we see some concrete examples.
And just to say a couple of words about each of those, and even for those that for which this is this
is old hat, I hope to say a few more interesting things.
So key value pairs.
All data is represented this way in JSON.
It's like name and then a colon.
And then Alice.
It's a key colon a value.
Or it could be age colon 30 or it could be colon false.
And it could also be middle name colon null.
So there's a few things to point out here.
The first of them is that whenever you have strings text, you put double quotes around it like you
see here.
Like name and Alice have double quotes.
Numbers do not have quotes.
They are just numbers as it appears there.
Uh, you could also see that that uh, booleans, trues and falses, they come as true and false in
lowercase.
Like, you see, they're false in lowercase.
People from a Python background are used to it being a bit different.
This is what it is in JavaScript, in JSON.
And then that last one, null is a special thing that you're probably familiar with.
That means kind of empty.
And that is also a value, an acceptable value.
So just a few things to point out.
First of all, you need to use double quotes, not single quotes.
And that's a little trap to watch out for.
Uh, and also not curly quotes.
If you type something in in many word processors, it will automatically convert your quote marks into
curlies to go around the the words, and that will cause problems in JSON.
They have to be straight up single quotes.
True and false are in lowercase, and it's best practice when you have your keys to not have a space
in your key, but to use something like the you see, I use the underscore here instead of a space for
is student.
Now it's actually allowed.
You can have spaces in keys, but they tend to cause a few problems in various ways.
That means that it's probably not worth the trouble.
Better not to have spaces in the keys as a general principle.
Okay, so that's number one.
Key value pairs okay.
Secondly, the object.
So an object represents a thing with a bunch of key value pairs.
And the way you write an object is using curly brackets.
Curly braces as are sometimes known.
So you open a curly brace it means okay I've got an object for you here.
And then we have a key value pair.
The name is Alice, and that comma at the end signifies that there's another key value pair to come.
And it is age is 30.
And then a comma there's more is student is false.
And then a comma middle name is null.
And then no comma means end of object.
Close curly braces.
And we are done defining this object.
Okay.
And just a few things to note.
First of all, it's common to write it this way, with this kind of white space, with the things indented
like this, so that it's really easy for humans like you and me to look at this and, and see what it
means that it's an object, but it actually doesn't matter for the machine.
You can choose to indent it and space things out with empty lines like this.
Or you could write it all on one line.
It's the same thing.
And also, as I mentioned, it's it's worth noting that that last element there must not have a comma,
that last key value pair.
And again that's a difference.
Some people in other programming languages, if you're Python, then you know that it's fine to put
a comma at the end of the last entry, but not with JSON.
Okay.
That's number two okay.
Number three is an array.
And you probably know this.
An array is something which has square brackets around it.
So this would be an array of three fruits apples bananas oranges.
You have an element and a comma another element comma another element.
And here's here's another array.
This is a series 11235 if you know what that is.
And you can also mix.
You can have numbers and booleans and text strings in there if you wish.
That's another array.
And you can write arrays like this.
And sometimes people do.
And so that would also make a good array.
An array you can think of as like a value.
So an array can be the value.
If you have a key value pair, you could have something like favorite fruits as the key.
And the value might be apples, bananas, oranges.
That would be a good value for the key favorite fruits.
And then finally, just to explain again that that it's it's fine to have things like lists which contain
objects.
So here's an example of a list which has two things in it two things and they are each objects.
The first one is an object which has a name Alice, age 30, in blue there.
And the second object is name Bob, age 35.
And these are two different objects that are part of the array that I'm showing you there.
And you can also have you can write it like this as well, which, which is a bit nicer, which is just
to show that it is a array with two elements.
The first one is Alice, the second one is Bob.
And then similarly an object can contain other objects.
So here is an object.
This is some sort of an address.
It has a street, a city and a country as three different keys in this object.
And what we could do is we could have this object.
Check this out.
This is a single object, and it is something which has a name, age and address as three different
keys in this object and that address key, the value for address.
It's not text, it's not a number.
It's not an array.
It's not a boolean.
It is itself an object in yellow.
In fact, it's the same one as I put in the box above.
It's that object which has street, city, country that is a smaller object, which is part of the bigger
object which contains Alice and her age.
So that gives you just a sense that objects can be made up of other objects, and of course also of
arrays.
And if you knew all this already, then congratulations.
If you didn't, then hopefully this gave you just a bit of intuition.
Don't worry about it, because we're going to see so much of this, it will become second nature.
Just to give you some some of the lay of the land before we dive in.
All right.
Next up we're going to talk about expressions.