SlideShare a Scribd company logo
1 of 5
Download to read offline
978-1-491-92948-3
[LSI]
Introduction to JavaScript Object Notation
by Lindsay Bassett
Copyright © 2015 Lindsay Bassett. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are
also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/
institutional sales department: 800-998-9938 or corporate@oreilly.com.
Editor: Meg Foley
Production Editor: Kristen Brown
Copyeditor: Jasmine Kwityn
Proofreader: Charles Roumeliotis
Indexer: Ellen Troutman
Interior Designer: David Futato
Cover Designer: Karen Montgomery
Illustrator: Rebecca Demarest
August 2015: First Edition
Revision History for the First Edition
2015-08-04: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781491929483 for release details.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Introduction to JavaScript Object Nota‐
tion, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc.
While the publisher and the author have used good faith efforts to ensure that the information and
instructions contained in this work are accurate, the publisher and the author disclaim all responsibility
for errors or omissions, including without limitation responsibility for damages resulting from the use of
or reliance on this work. Use of the information and instructions contained in this work is at your own
risk. If any code samples or other technology this work contains or describes is subject to open source
licenses or the intellectual property rights of others, it is your responsibility to ensure that your use
thereof complies with such licenses and/or rights.
Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
1. What Is JSON?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
JSON Is a Data Interchange Format 1
JSON Is Programming Language Independent 2
Key Terms and Concepts 4
2. JSON Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
JSON Is Based on JavaScript Object Literals 5
Name-Value Pairs 6
Proper JSON Syntax 7
Syntax Validation 10
JSON as a Document 11
The JSON MediaType 11
Key Terms and Concepts 11
3. JSON Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Quick Look at Data Types 13
The JSON Data Types 15
The JSON Object Data Type 16
The JSON String Data Type 17
The JSON Number Data Type 19
The JSON Boolean Data Type 20
The JSON Null Data Type 20
The JSON Array Data Type 21
Key Terms and Concepts 26
iii
4. JSON Schema. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Contracts with Validation Magic 30
Introduction to JSON Schema 31
Key Terms and Concepts 36
5. JSON Security Concerns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
A Quick Look at Client- and Server-Side Relationships 39
Cross-Site Request Forgery (CSRF) 40
Injection Attacks 43
Cross-Site Scripting (XSS) 43
Holes in Security: Architectural Decisions 45
Key Terms and Concepts 46
6. The JavaScript XmlHttpRequest and Web APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Web APIs 50
The JavaScript XMLHttpRequest 53
Relationship Woes and Rules About Sharing 57
Cross-Origin Resource Sharing (CORS) 57
JSON-P 58
Key Terms and Concepts 60
7. JSON and Client-Side Frameworks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
jQuery and JSON 64
AngularJS 66
Key Terms and Concepts 71
8. JSON and NoSQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
The CouchDB Database 74
The CouchDB API 77
Key Terms and Concepts 85
9. JSON on the Server Side. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Serializing, Deserializing and Requesting JSON 88
ASP.NET 88
PHP 92
A Smorgasbord of JSON HTTP Requests 96
Ruby on Rails 97
Node.js 98
Java 98
Key Terms & Concepts 99
iv | Table of Contents
10. Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
JSON as a Configuration File 101
The Big Picture 104
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Table of Contents | v

More Related Content

Similar to Introduction to JavaScript Object Notation, Lindsay Bassett, 2015

Martin Kleppmann-Designing Data-Intensive Applications_ The Big Ideas Behind ...
Martin Kleppmann-Designing Data-Intensive Applications_ The Big Ideas Behind ...Martin Kleppmann-Designing Data-Intensive Applications_ The Big Ideas Behind ...
Martin Kleppmann-Designing Data-Intensive Applications_ The Big Ideas Behind ...Samir Paul
 
Mongo db manual
Mongo db manualMongo db manual
Mongo db manualDan Llimpe
 
Visual Studio 2008 Beginning Asp Net 3 5 In C# 2008 From Novice To Professi...
Visual Studio 2008   Beginning Asp Net 3 5 In C# 2008 From Novice To Professi...Visual Studio 2008   Beginning Asp Net 3 5 In C# 2008 From Novice To Professi...
Visual Studio 2008 Beginning Asp Net 3 5 In C# 2008 From Novice To Professi...guest4c5b8c4
 
RDB Synchronization, Transcoding and LDAP Directory Services ...
RDB Synchronization, Transcoding and LDAP Directory Services ...RDB Synchronization, Transcoding and LDAP Directory Services ...
RDB Synchronization, Transcoding and LDAP Directory Services ...Videoguy
 
46061598 xml-data-exchange-using-abap
46061598 xml-data-exchange-using-abap46061598 xml-data-exchange-using-abap
46061598 xml-data-exchange-using-abapGerda_Meier
 
R data mining_clear
R data mining_clearR data mining_clear
R data mining_clearsinanspoon
 
irmpg_3.7_python_202301.pdf
irmpg_3.7_python_202301.pdfirmpg_3.7_python_202301.pdf
irmpg_3.7_python_202301.pdfFernandoBello39
 
How To Do Everything With JavaScript
How To Do Everything With JavaScriptHow To Do Everything With JavaScript
How To Do Everything With JavaScriptAzharul Haque Shohan
 
Progress OpenEdge database administration guide and reference
Progress OpenEdge database administration guide and referenceProgress OpenEdge database administration guide and reference
Progress OpenEdge database administration guide and referenceVinh Nguyen
 
7 1-1 soap-developers_guide
7 1-1 soap-developers_guide7 1-1 soap-developers_guide
7 1-1 soap-developers_guideNugroho Hermanto
 
www.webre24h.com - [Wordware] advanced javascript, 3rd ed. - [easttom]
www.webre24h.com - [Wordware]   advanced javascript, 3rd ed. - [easttom]www.webre24h.com - [Wordware]   advanced javascript, 3rd ed. - [easttom]
www.webre24h.com - [Wordware] advanced javascript, 3rd ed. - [easttom]webre24h
 
20220311-EB-Designing_Event_Driven_Systems.pdf
20220311-EB-Designing_Event_Driven_Systems.pdf20220311-EB-Designing_Event_Driven_Systems.pdf
20220311-EB-Designing_Event_Driven_Systems.pdfpeerbashap
 

Similar to Introduction to JavaScript Object Notation, Lindsay Bassett, 2015 (20)

Silverlight
SilverlightSilverlight
Silverlight
 
R data
R dataR data
R data
 
Martin Kleppmann-Designing Data-Intensive Applications_ The Big Ideas Behind ...
Martin Kleppmann-Designing Data-Intensive Applications_ The Big Ideas Behind ...Martin Kleppmann-Designing Data-Intensive Applications_ The Big Ideas Behind ...
Martin Kleppmann-Designing Data-Intensive Applications_ The Big Ideas Behind ...
 
Mongo db manual
Mongo db manualMongo db manual
Mongo db manual
 
Mongo db manual
Mongo db manualMongo db manual
Mongo db manual
 
Visual Studio 2008 Beginning Asp Net 3 5 In C# 2008 From Novice To Professi...
Visual Studio 2008   Beginning Asp Net 3 5 In C# 2008 From Novice To Professi...Visual Studio 2008   Beginning Asp Net 3 5 In C# 2008 From Novice To Professi...
Visual Studio 2008 Beginning Asp Net 3 5 In C# 2008 From Novice To Professi...
 
RDB Synchronization, Transcoding and LDAP Directory Services ...
RDB Synchronization, Transcoding and LDAP Directory Services ...RDB Synchronization, Transcoding and LDAP Directory Services ...
RDB Synchronization, Transcoding and LDAP Directory Services ...
 
46061598 xml-data-exchange-using-abap
46061598 xml-data-exchange-using-abap46061598 xml-data-exchange-using-abap
46061598 xml-data-exchange-using-abap
 
Angular js book
Angular js bookAngular js book
Angular js book
 
Angularjs
AngularjsAngularjs
Angularjs
 
Angularjs
AngularjsAngularjs
Angularjs
 
Vba uk
Vba ukVba uk
Vba uk
 
R data mining_clear
R data mining_clearR data mining_clear
R data mining_clear
 
irmpg_3.7_python_202301.pdf
irmpg_3.7_python_202301.pdfirmpg_3.7_python_202301.pdf
irmpg_3.7_python_202301.pdf
 
How To Do Everything With JavaScript
How To Do Everything With JavaScriptHow To Do Everything With JavaScript
How To Do Everything With JavaScript
 
Progress OpenEdge database administration guide and reference
Progress OpenEdge database administration guide and referenceProgress OpenEdge database administration guide and reference
Progress OpenEdge database administration guide and reference
 
7 1-1 soap-developers_guide
7 1-1 soap-developers_guide7 1-1 soap-developers_guide
7 1-1 soap-developers_guide
 
www.webre24h.com - [Wordware] advanced javascript, 3rd ed. - [easttom]
www.webre24h.com - [Wordware]   advanced javascript, 3rd ed. - [easttom]www.webre24h.com - [Wordware]   advanced javascript, 3rd ed. - [easttom]
www.webre24h.com - [Wordware] advanced javascript, 3rd ed. - [easttom]
 
Jdbc
JdbcJdbc
Jdbc
 
20220311-EB-Designing_Event_Driven_Systems.pdf
20220311-EB-Designing_Event_Driven_Systems.pdf20220311-EB-Designing_Event_Driven_Systems.pdf
20220311-EB-Designing_Event_Driven_Systems.pdf
 

Recently uploaded

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 

Recently uploaded (20)

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 

Introduction to JavaScript Object Notation, Lindsay Bassett, 2015

  • 1.
  • 2. 978-1-491-92948-3 [LSI] Introduction to JavaScript Object Notation by Lindsay Bassett Copyright © 2015 Lindsay Bassett. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/ institutional sales department: 800-998-9938 or corporate@oreilly.com. Editor: Meg Foley Production Editor: Kristen Brown Copyeditor: Jasmine Kwityn Proofreader: Charles Roumeliotis Indexer: Ellen Troutman Interior Designer: David Futato Cover Designer: Karen Montgomery Illustrator: Rebecca Demarest August 2015: First Edition Revision History for the First Edition 2015-08-04: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781491929483 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Introduction to JavaScript Object Nota‐ tion, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
  • 3. Table of Contents Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii 1. What Is JSON?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 JSON Is a Data Interchange Format 1 JSON Is Programming Language Independent 2 Key Terms and Concepts 4 2. JSON Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 JSON Is Based on JavaScript Object Literals 5 Name-Value Pairs 6 Proper JSON Syntax 7 Syntax Validation 10 JSON as a Document 11 The JSON MediaType 11 Key Terms and Concepts 11 3. JSON Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Quick Look at Data Types 13 The JSON Data Types 15 The JSON Object Data Type 16 The JSON String Data Type 17 The JSON Number Data Type 19 The JSON Boolean Data Type 20 The JSON Null Data Type 20 The JSON Array Data Type 21 Key Terms and Concepts 26 iii
  • 4. 4. JSON Schema. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Contracts with Validation Magic 30 Introduction to JSON Schema 31 Key Terms and Concepts 36 5. JSON Security Concerns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 A Quick Look at Client- and Server-Side Relationships 39 Cross-Site Request Forgery (CSRF) 40 Injection Attacks 43 Cross-Site Scripting (XSS) 43 Holes in Security: Architectural Decisions 45 Key Terms and Concepts 46 6. The JavaScript XmlHttpRequest and Web APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Web APIs 50 The JavaScript XMLHttpRequest 53 Relationship Woes and Rules About Sharing 57 Cross-Origin Resource Sharing (CORS) 57 JSON-P 58 Key Terms and Concepts 60 7. JSON and Client-Side Frameworks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 jQuery and JSON 64 AngularJS 66 Key Terms and Concepts 71 8. JSON and NoSQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 The CouchDB Database 74 The CouchDB API 77 Key Terms and Concepts 85 9. JSON on the Server Side. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Serializing, Deserializing and Requesting JSON 88 ASP.NET 88 PHP 92 A Smorgasbord of JSON HTTP Requests 96 Ruby on Rails 97 Node.js 98 Java 98 Key Terms & Concepts 99 iv | Table of Contents
  • 5. 10. Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 JSON as a Configuration File 101 The Big Picture 104 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Table of Contents | v