One thing I’ve learned during my journey as a web developer is that no matter how devoted I am to its subjects in spirit, finding time for said devotion is another matter. The rapidly evolving world of technology is not concerned about how busy anyone is. It does not say, “Relax, take your time to study, I understand you have a family and quiet time for studying is difficult to come by.” What it says is, “Keep evolving, or become obsolete.”
I wrote this book with that sentiment in mind. This book is slim—it intentionally avoids subjects like “the history of JSON.”
Although I am grateful to Douglas Crockford for discovering JSON, I make no mention of him or the years during which JSON evolved into what it is today. This book is about what it is today. If you want to read about this history of JSON, Wikipedia has an excellent summary.
This book aims to shoot for the very heart of the subject of JSON. It is about getting to the point and getting you started quickly. It is for the busy IT professional.
As I wrote this book for the busy IT professional, I also thought quite a bit about who you are. You could be a beginning frontend web developer. Or perhaps you’ve been focused on server-side web application development for years, and now you need to learn JSON for a web API. You could be a PHP, Ruby, C, Java, or ASP.NET developer. That list goes on. A lot of different people in different roles want and need to learn JSON.
In this book, I avoid excessive jargon and explain prerequisite concepts for those new to web programming. I try to speak to all of you. However, I must make a few assumptions about what knowledge you already have. If you are new to web development, this should not be the very first book you pick up.
I assume you have at least a basic understanding of:
<script>
tag, function, and variable are. It’s OK if you are only a beginner. I keep my code examples simple.Countless times over the years I’ve needed to learn new technologies, often during a project with a deadline. I buy big books, wade through tutorials, and try to absorb enough information to know what I’m doing. While I’m wading through hundreds of pages, I’m looking for the answers to these three basic questions:
When I wrote this book, I sought to get to the point with these questions, so you don’t have to wade through to find the answers.
In Chapters 1–4, we will explore JSON at a low level. First, I will answer the ultimate question of “What is it?” From there, we will look at syntax, syntax validation, data types, and schema validation.
In Chapter 5, we will take a look at the important subject of security concerns. This chapter includes a primer on client-side and server-side concepts that are important to the remainder of the book. This chapter will answer the question of “How can the bad guys use it?”
The remaining chapters examine the many roles that JSON plays as a data interchange format. These chapters aim to answer the question, “How can I use it?”
These chapters include many examples of JSON, and technologies interacting with JSON. Some important things to note about Chapters 6–9:
I cover several technologies, such as jQuery, AngularJS, and CouchDB, at a high level. Each of these subjects are large enough that an entire book can (and has) been written about them. I intentionally leave out installation instructions and deeper explanations about the technologies themselves. The point is to expose you to how these technologies are using JSON.
If you want to try out the examples shown for these technologies, you’ll need to do some legwork to set everything up. However, the examples are simple. If you get things up and running at a basic level, you should be able to give them a whirl.
You will see many code examples in this book, some in programming languages that might be new to you. The syntax will not be explained for these languages. Do not be alarmed if you don’t understand the syntax. The point is for you to “get the gist” of what the code is doing, and the explanation of what the code is doing shall be provided.
All of the code examples used in this book are available on this book’s GitHub repository.
The ultimate point of Chapters 6–9 is to expose you to how JSON is being used out in the world today, and to get your idea wheels spinning for your own projects. If you never saw JSON being used as a document in a document store database, would you think to use it in a project? Knowing is half the battle.
In each chapter, a balance is sought between getting to the point and giving you enough information so that you are not left with any major holes in your education. Ultimately, the entire book is structured to get you up and running with JSON quickly, without sacrificing the deeper understanding of what JSON is and the purposes it may serve.
The following typographical conventions are used in this book:
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
This element signifies a tip or suggestion.
This element signifies a general note.
This element indicates a warning or caution.
Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/lindsaybassett/json.
This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Introduction to JavaScript Object Notation by Lindsay Bassett (O’Reilly). Copyright 2015 Lindsay Bassett, 978-1-491-92948-3.”
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at [email protected].
Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.
Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.
Safari Books Online offers a range of plans and pricing for enterprise, government, education, and individuals.
Members have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and hundreds more. For more information about Safari Books Online, please visit us online.
Please address comments and questions concerning this book to the publisher:
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://bit.ly/intro_JS_object_notation.
To comment or ask technical questions about this book, send email to [email protected].
For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
First off, I’d like to thank my husband, Rhett, for his encouragement and support in all of my writing endeavors, and for being understanding on all of those days where I was hiding in the dark hunched over my laptop.
I’d also like to thank Douglas Crockford for creating JSON and giving me something fun to write about. I’m so grateful to my technical reviewers, Shelley Powers and Tom Marrs, for their constructive feedback that helped evolve this book. Any errors are my own.
My editor, Meg Foley, was an absolute joy to work with.
Finally, I’d like to thank O’Reilly for giving my book a home and releasing it into the wild. I’ve always been a big fan of O’Reilly books, and after working with O’Reilly this year, I’m an even bigger fan.
3.12.108.175