Chapter 3. JSON Data Types
If you’ve already learned a programming language or two, you likely have an understanding of data types. If not, that’s OK too. Let’s take a quick look.
Quick Look at Data Types
Imagine what would happen if you hand a little boy that knows nothing about tools a hammer, and you don’t tell him what it’s for. Property and bodily damage would likely occur. If this child is well behaved and coordinated, we could give this child a set of instructions for using the hammer. Instead of running around damaging things, the child would only ever use it for hammering nails and removing them (it’s a well-behaved child, remember). Additionally, when you say to the child, “Will you pass me the hammer, please?”, he doesn’t hand you the screwdriver. Knowing what something is ahead of time and how to use it is as useful in computing as it is in the real world.
In computing, we most often need to know what type of data we are dealing with because we can do different things with different types of data. I can multiply a number by another number, but I can’t multiply a word by another number. If I have a list of words, I can sort them alphabetically. I can’t sort the number 5 alphabetically. So, in programming, when a method (or function) says, “Will you pass me the number, please?”, if we know what a number is, we won’t make the mistake of passing it the word “ketchup.”
In computer science, there is a set of data types referred to as primitive data types. The word “primitive” ...
Get Introduction to JavaScript Object Notation now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.