Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

JSON Syntax Rules

  • Data is represented in name/value pairs.
  • Items are separated by commas.
  • Objects are enclosed in curly braces.
  • Arrays are enclosed in square brackets.

JSON Data – A Name and a Value

JSON data is written as name/value pairs, similar to JavaScript object properties.

Each name/value pair consists of a field name (in double quotes), followed by a colon, and then the value.

“firstName”:“John”
In JSON, names must be enclosed in double quotes, whereas in JavaScript, names do not require quotes.

JSON Objects

JSON objects are enclosed in curly braces.

Similar to JavaScript, objects can contain multiple name/value pairs.

{“firstName”:“John”“lastName”:“Doe”}