Table of Contents for
JSON at Work
Close
Version ebook
/
Retour
JSON at Work
by Tom Marrs
Published by O'Reilly Media, Inc., 2017
nav
Cover
JSON at Work
JSON at Work
Dedication
Preface
I. JSON Overview and Platforms
1. JSON Overview
2. JSON in JavaScript
3. JSON in Ruby on Rails
4. JSON in Java
II. The JSON Ecosystem
5. JSON Schema
6. JSON Search
7. JSON Transform
III. JSON in the Enterprise
8. JSON and Hypermedia
9. JSON and MongoDB
10. JSON Messaging with Kafka
A. Installation Guides
B. JSON Community
Index
About the Author
Colophon
Preface
Audience, Assumptions, and Approach
What Does “At Work” Mean?
What You’ll Learn
What You’ll Work With
Who This Book Is Not For
Organization
Part I, JSON Overview and Platforms
Part II, The JSON Ecosystem
Part III, JSON in the Enterprise
Appendices
Code Examples
O’Reilly Safari
How to Contact Us
Acknowledgments
I. JSON Overview and Platforms
1. JSON Overview
JSON Is a Standard
A Brief Sample
Why JSON?
Core JSON
JSON Data Types
JSON Value Types
JSON Versions
JSON Comments
JSON File and MIME Type
JSON Style Guidelines
Our Example—MyConference
Our Technical Stack
Our Architectural Style—noBackEnd
Model JSON Data with JSON Editor Online
Generate Sample JSON Data with JSON Generator
Create and Deploy a Stub API
What We Covered?
What’s Next?
2. JSON in JavaScript
Node.js Setup
JSON Serialization/Deserialization with JSON.stringify() and JSON.parse()
The JSON Stringifier/Parser Object
JSON Serialization with Simple JavaScript Data Types
JSON Serialization with an Object and toJSON()
JSON Deserialization Using eval()
JSON Deserialization with an Object and JSON.parse()
JavaScript Objects and JSON
Node REPL
Where to Learn More About JavaScript Objects
Unit Testing with a Stub API
Unit Test Style—TDD and BDD
Just Enough Unit Testing with Mocha and Chai
Setting Up the Unit Test
Unirest
Test Data
Speakers Unit Test
Building a Small Web Application
Yeoman
Iteration 1—Generate a Web Application with Yeoman
Iteration 2—Make an HTTP Call with jQuery
Iteration 3—Consume Speaker Data from a Stub API and Use a Template
How to Go Deeper with JavaScript
What We Covered
What’s Next?
3. JSON in Ruby on Rails
Ruby on Rails Setup
Ruby JSON Gems
JSON Serialization/Deserialization with MultiJson
The MultiJson Object
JSON Serialization/Deserialization with Simple Ruby Data Types
JSON Deserialization with Objects and MultiJson
A Word on Camel Casing and JSON
JSON Serialization with Objects and ActiveSupport
JSON Deserialization with Objects and ActiveSupport
Unit Testing with a Stub API
Just Enough Unit Testing with Minitest
Setting Up the Unit Test
Test Data
JSON and Minitest Testing with APIs
Speakers Unit Test
Further Reading on Ruby and Minitest
What Is Missing in the Unit Tests?
Build a Small Web API with Ruby on Rails
Choose a JSON Serializer
speakers-api-1—Create an API with Camel-Cased JSON
speakers-api-2—Create an API that Customizes the JSON Representation
Further Reading on Rails and Rails-based APIs
What We Covered
What’s Next?
4. JSON in Java
Java and Gradle Setup
Gradle Overview
Just Enough Unit Testing with JUnit
Java-Based JSON Libraries
JSON Serialization/Deserialization with Jackson
Serialization/Deserialization with Simple Java Data Types
Serialization/Deserialization with Java Objects
Unit Testing with a Stub API
Test Data
JSON and JUnit Testing with APIs
Build a Small Web API with Spring Boot
Create the Model
Create the Controller
Register the Application
Write the Build Script
Deploy the API
Test the API with Postman
What We Covered
What’s Next?
II. The JSON Ecosystem
5. JSON Schema
JSON Schema Overview
What Is JSON Schema?
Syntactic Versus Semantic Validation
A Simple Example
JSON Schema on the Web
Why JSON Schema?
My Journey with JSON Schema
The Current State of the JSON Schema Standard
JSON Schema and XML Schema
Core JSON Schema—Basics and Tooling
JSON Schema Workflow and Tooling
Core Keywords
Basic Types
Numbers
Arrays
Enumerated Values
Objects
Pattern Properties
Regular Expressions
Dependent Properties
Internal References
External References
Choosing Validation Rules
How to Design and Test an API with JSON Schema
Our Scenario
Model a JSON Document
Generate a JSON Schema
Validate the JSON Document
Generate Sample Data
Deploy a Stub API with json-server
Final Thoughts on API Design and Testing with JSON Schema
Validation Using a JSON Schema Library
Where to Go Deeper with JSON Schema
What We Covered
What’s Next?
6. JSON Search
Why JSON Search?
JSON Search Libraries and Tools
Honorable Mention
What to Look For
Test Data
Setting Up Unit Tests
Comparing JSON Search Libraries and Tools
JSONPath
JSON Pointer
jq
JSON Search Library and Tool Evaluations—The Bottom Line
What We Covered
What’s Next?
7. JSON Transform
Types of JSON Transformation
What to Look For in a JSON Transform Library
Test Input Data
JSON-to-HTML Transformation
Target HTML Document
Mustache
Handlebars
JSON-to-HTML Transformation Evaluations—The Bottom Line
JSON-to-JSON Transform
The Issues
JSON-to-JSON Transform Libraries
Honorable Mention
Target JSON Output
JSON Patch
JSON-T
Mustache
Handlebars
JSON-to-JSON Transformation Evaluations—The Bottom Line
JSON-XML Transformation
JSON-XML Transformation Conventions
The Issues with JSON-XML Transformation Conventions
XML-JSON Transform—The Bottom Line
JSON-XML Transformation Unit Test
What We Covered
What’s Next?
III. JSON in the Enterprise
8. JSON and Hypermedia
Comparing Hypermedia Formats
Defining Key Terms
My Opinion on Hypermedia
Siren
JSON-LD
Collection+JSON
json:api
HAL
Conclusions on Hypermedia
Recommendations for Working with Hypermedia
Practical Issues with Hypermedia
Testing with HAL in the Speakers API
Test Data
HAL Unit Test
Server-Side HAL
Going Deeper with Hypermedia
What We Covered
What’s Next?
9. JSON and MongoDB
What About BSON?
MongoDB Setup
MongoDB Server and Tools
MongoDB Server
Importing JSON into MongoDB
MongoDB Command Shell
Basic CRUD with mongo
Exporting from MongoDB to a JSON Document
What About Schema?
RESTful API Testing with MongoDB
Test Input Data
Providing a RESTful Wrapper for MongoDB
What We Covered
What’s Next?
10. JSON Messaging with Kafka
Kafka Use Cases
Kafka Concepts and Terminology
The Kafka Ecosystem—Related Projects
Kafka Environment Setup
Why Do I Need ZooKeeper?
Kafka Command-Line Interface (CLI)
How to Publish a JSON Message with the CLI
Start ZooKeeper
Start Kafka
Create a Topic
List Topics
Start a Consumer
Publish a JSON Message
Consume a JSON Message
Clean Up and Shut Down Kafka
Kafka Libraries
End-to-End Example—Speaker Proposals at MyConference
Test Data
Architecture Components
Set Up the Kafka Environment
Set Up Fake Email Server and Client—MailCatcher
Set Up Node.js Project Environment
Speaker Proposal Producer (Send Speaker Proposals)
Proposal Reviewer (Consumer/Producer)
Speaker Notifier (Consumer)
Review Notification Email Messages with MailCatcher
What We Covered
A. Installation Guides
Install JSON Tools in the Browser
Install JSONView in Chrome and Firefox
JSONLint
JSON Editor Online
Install Postman
Install Node.js
Install Node.js on macOS and Linux with NVM
Install Node.js on Windows
Uninstall Node.js
Install Yeoman
Install npm Modules
Install Ruby on Rails
Install Rails on macOS and Linux
Install Rails on Windows
Install Ruby Gems
Install MongoDB
Install the Java Environment
Install Java SE
Install Gradle
Install jq
Install cURL
Install cURL on macOS
Install cURL on Linux
Install cURL on Windows
Install Apache Kafka
Install Kafka on macOS
Install Kafka on UNIX
Install Kafka on Windows
References
B. JSON Community
Index