Book description
Over 80 recipes to make the most of JSON in your desktop, server, web, and mobile applications
In Detail
JSON (JavaScript Object Notation) is a lightweight text-based data interchange format used to create objects to transfer data over the Internet. It's widely used today by common web applications, as well as mobile applications.
This book gives you clear ways that you can exchange objects using JSON, regardless of whether you're developing a web or traditional networked application. You'll start with a brief refresher on JSON and JavaScript syntax and read and write on the client and server. Then, you'll learn how to use JSON in simple AJAX applications using AngularJS and jQuery. Next, you will learn how to exchange objects with databases using MongoDB and CouchDB. You'll also explore how to use JSON in a type-safe manner, writing programs that have fewer bugs.
What You Will Learn
- Learn to use JSON in a type-safe way to avoid common data typing errors
- Exchange data with NoSQL databases such as MongoDB and CouchDB with JSON
- Make the most of JSON in AJAX web applications, with or without a framework
- Exchange data between servers and mobile applications running on Android and iOS with JSON
- Practical examples to show you how to leverage JSON from a variety of application domains
Table of contents
-
JavaScript JSON Cookbook
- Table of Contents
- JavaScript JSON Cookbook
- Credits
- About the Author
- About the Reviewers
- www.PacktPub.com
- Preface
- 1. Reading and Writing JSON on the Client
- 2. Reading and Writing JSON on the Server
- 3. Using JSON in Simple AJAX Applications
-
4. Using JSON in AJAX Applications with jQuery and AngularJS
- Introduction
- Adding a dependency to jQuery to your web page
- Requesting JSON content using jQuery
- Sending JSON to your web server using jQuery
- Getting the progress of a request using jQuery
- Parsing the returned JSON using jQuery
- Adding a dependency to AngularJS to your web page
- Requesting JSON content using AngularJS
- Sending JSON to your web server using AngularJS
- Getting the progress of a request using AngularJS
- Parsing the returned JSON using AngularJS
-
5. Using JSON with MongoDB
- Introduction
- Setting up MongoDB
- Installing the MongoDB database driver for Node.js
- Installing the express module for Node.js
- Connecting to a MongoDB database using Node.js
- Creating a document in MongoDB using Node.js
- Searching for a document in MongoDB with Node.js
- Updating a document in MongoDB with Node.js
- Deleting a document in MongoDB using Node.js
- Using REST to search MongoDB
- Using REST to create a document in MongoDB
- Using REST to update a document in MongoDB
- Using REST to delete a document in MongoDB
-
6. Using JSON with CouchDB
- Introduction
- Installing and setting up CouchDB and Cradle
- Connecting to a CouchDB database using Node.js and Cradle
- Creating a CouchDB database using Node.js and Cradle
- Creating a document in CouchDB using Node.js and Cradle
- Setting up a data view in CouchDB with Node.js and Cradle
- Searching for a document in CouchDB with Node.js and Cradle
- Updating a document in CouchDB with Node.js and Cradle
- Deleting a document in CouchDB using Node.js and Cradle
- Using REST to enumerate CouchDB records
- Using REST to search CouchDB
- Using REST to upsert a document in CouchDB
- Using REST to delete a document in CouchDB
-
7. Using JSON in a Type-safe Manner
- Introduction
- How to deserialize an object using Json.NET
- How to handle date and time objects using Json.NET
- How to deserialize an object using gson for Java
- How to use TypeScript with Node.js
- How to annotate simple types using TypeScript
- How to declare interfaces using TypeScript
- How to declare classes with interfaces using TypeScript
- Using json2ts to generate TypeScript interfaces from your JSON
-
8. Using JSON for Binary Data Transfer
- Introduction
- Encoding binary data as a base64 string using Node.js
- Decoding binary data from a base64 string using Node.js
- Encoding and decoding binary data as a base64 string using JavaScript in the browser
- Encoding data as BSON using Json.NET
- Decoding data from BSON using Json.NET
- Using a DataView to access an ArrayBuffer
- Encoding and decoding base64 using an ArrayBuffer
- Compressing object-body content from a Node.js server built using the express module
-
9. Querying JSON with JSONPath and LINQ
- Introduction
- Using the JSONPath dot-notation to query JSON documents
- Using JSONPath bracket-notation to query JSON documents
- Using JSONPath scripting to construct more complicated queries
- Using JSONPath in your web application
- Using JSONPath in your Node.js application
- Using JSONPath in your PHP application
- Using JSONPath in your Python application
- Using JSONPath in your Java application
- Using JSONPath with SelectToken to query for JSONPath expressions in your C# application
- Using LINQ with Json.NET to query JSON in your C# application
- 10. JSON on Mobile Platforms
- Index
Product information
- Title: JavaScript JSON Cookbook
- Author(s):
- Release date: June 2015
- Publisher(s): Packt Publishing
- ISBN: 9781785286902
You might also like
book
JavaScript Cookbook, 3rd Edition
Why reinvent the wheel every time you run into a problem with JavaScript? This cookbook is …
book
JSON Quick Syntax Reference
This compact quick scripting syntax reference on JSON covers syntax and parameters central to JSON object …
book
Get Programming with Node.js
Get Programming with Node.js Get Programming with Node.js teaches you to write server-side code in JavaScript …
book
MySQL and JSON: A Practical Programming Guide
Practical instruction on using JavaScript Object Notation (JSON) with MySQL This hands-on guide teaches, step by …