You are previewing Beginning JSON.
O'Reilly logo
Beginning JSON

Book Description

Beginning JSON is the definitive guide to JSON - JavaScript Object Notation - today’s standard in data formatting for the web. The book starts with the basics, and walks you through all aspects of using the JSON format. Beginning JSON covers all areas of JSON from the basics of data formats to creating your own server to store and retrieve persistent data. Beginning JSON provides you with the skill set required for reading and writing properly validated JSON data.

The first two chapters of the book will discuss the foundations of JavaScript for those who need it, and provide the necessary understandings for later chapters. Chapters 3 through 12 will uncover what data is, how to convert that data into a transmittable/storable format, how to use AJAX to send and receive JSON, and, lastly, how to reassemble that data back into a proper JavaScript object to be used by your program. The final chapters put everything you learned into practice.

Table of Contents

  1. Cover
  2. Title
  3. Copyright
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. About the Author
  8. About the Technical Reviewer
  9. Acknowledgments
  10. Introduction
  11. Chapter 1: JavaScript Basics
    1. JavaScript History
    2. JavaScript Essentials
    3. Values
      1. Primitive Types
    4. Expressions
      1. Operators
    5. Statements
      1. Line Terminators
      2. Control Statements
      3. Block Statements
      4. Truthy/Falsy
      5. Loop Statements
    6. Declarations
      1. Variables
    7. Functions
    8. Summary
      1. Key Points from This Chapter
  12. Chapter 2: Special Objects
    1. Objects
    2. Objects Are Collections
    3. Built-in Objects
    4. Object
    5. Creating Objects
    6. Access Notation
    7. Array
    8. Object Literals
    9. Designing Literals
      1. The Object Literal
      2. The Array Literal
    10. Summary
      1. Key Points from This Chapter
  13. Chapter 3: String Manipulation
    1. String Concatenation
    2. The String Object
    3. Creating String Objects
    4. The Interface of the String Object
      1. length
      2. toString
      3. charAt
      4. indexOf
      5. lastIndexOf
      6. match
      7. replace
      8. slice
      9. substr
      10. split
      11. toUpperCase
      12. toLowerCase
    5. The Implicit String Object
    6. Summary
      1. Key Points from This Chapter
  14. Chapter 4: Introducing JSON
    1. History
    2. JSON Grammar
      1. Composite Structures
      2. JSON Values
    3. JSON Tokens
    4. Summary
      1. Key Points from This Chapter
  15. Chapter 5: Creating JSON
    1. The Serialization Process—Demystified
    2. The JSON Object
      1. stringify
    3. Summary
      1. Key Points from This Chapter
  16. Chapter 6: Parsing JSON
    1. JSON.parse
      1. eval
      2. reviver
    2. Summary
      1. Key Points from This Chapter
  17. Chapter 7: Persisting JSON: I
    1. HTTP Cookie
      1. Syntax
    2. document.cookie
    3. Web Storage
      1. Web Storage Interface
    4. Summary
      1. Key Points from This Chapter
  18. Chapter 8: Data Interchange
    1. Hypertext Transfer Protocol
      1. HTTP-Request
      2. HTTP Response
    2. Ajax
    3. XMLHttpRequest Interface
      1. Global Aspects
      2. The Request Aspect
      3. The Response Aspect
      4. Obtaining the Response
    4. Summary
      1. Key Points from This Chapter
  19. Chapter 9: X-Origin Resources
    1. Same-Origin Policy
    2. Circumventing Same-Origin Policy
      1. CORS
      2. The Proxy
      3. JSONP
    3. Summary
      1. Key Points from This Chapter
  20. Chapter 10: Serving JSON
    1. Node.JS
      1. Windows Installation
      2. Mac Installation
    2. Building an HTTP Server
      1. Node HTTP Web Server
      2. Node API
      3. Modules
    3. The HTTP Module
      1. http.createServer
      2. http.IncomingMessage
      3. http.ServerResponse
      4. http.Server
    4. CORS-Enabled Server
    5. JSONP Server
    6. The Proxy Server
      1. http.request
      2. http.Stream
      3. http.ClientRequest
    7. Summary
      1. Key Points from This Chapter
  21. Chapter 11: Posting JSON
    1. Request Entity Body
      1. HTML Form POST
      2. Processing a JSON POST
    2. Preflight Request
      1. OPTIONS Request Method
      2. What Determines Preflight
    3. Summary
      1. Key Points from This Chapter
  22. Chapter 12: Persisting JSON: II
    1. CouchDB
      1. Windows Installation
      2. Mac Installation
    2. Working with CouchDB
      1. Futon
      2. Creating Views
      3. Creating Our First Custom View
    3. Connecting Node and CouchDB
      1. Cradle for Node
      2. Working with Databases
      3. Cradle Database API
      4. Creating Documents via Cradle
      5. Creating Design Documents via Cradle
    4. Summary
      1. Key Points from This Chapter
  23. Chapter 13: Working with Templates
    1. Templating Engine
    2. Handlebars
      1. Installation
    3. Working with Handlebars
      1. A Basic Expression
      2. The Role of <script>
      3. Compiling a Template
      4. Giving Context to Our Template
      5. Multiple Placeholders
      6. Complex JSON Structures
      7. Block Expressions
      8. Block Expressions and Arrays
    4. Applying Logic to Logic-less Templates
      1. Helpers
    5. Summary
      1. Key Points from This Chapter
  24. Chapter 14: Putting It All Together
    1. Twitter
      1. Twitter Apps
      2. Keys and Access Tokens
      3. Public Stream
      4. Your User Access Token
      5. #Trending
    2. Node.js
      1. Twitter Module
      2. Incorporating the Twitter Module
      3. Streaming API (Stable)
      4. Statuses/Filter
    3. CouchDB
      1. Incorporating the Cradle Module
      2. Creating a View
      3. Enabling CORS
    4. Ajax
      1. Requesting Ranges
    5. Handlebars
    6. Summary
  25. Index