resource11 / json-study

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSON Study

Objectives

By the end of this, students should be able to:

  • Explain why JSON is preferable to HTML or XML for sending data
  • Name three constraints of JSON over JavaScript object literals

Instructions

Read this document entirely. Follow any links and study their content. Readings and activities are required unless otherwise indicated.

JSON

JSON is a way to represent data. It's typically used to communicate data between a back-end (api) and a front-end (client). JSON is a string with a very specific format. JSON is formally defined here.

Example JSON strings are a great way to become familiar with the format.

JSON is not a dictionary. JSON is not an object, nor is it an object literal. JSON is only a string with a specific format.

JSON cannot have comments, since it is just a string. Putting comments in JSON, or otherwise treating JSON as if it is a JavaScript object literal, is a common source of hard-to-debug errors.

JSON cannot have methods, since it is a data exchange format. Since it only represents data, it cannot have behavior. It cannnot have behavior because it is not an object.

JSON only looks like an object. It is not an object.

About