From the course: JSON Essential Training

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Structure JSON by following the rules

Structure JSON by following the rules - JavaScript Tutorial

From the course: JSON Essential Training

Structure JSON by following the rules

- [Instructor] The basic structure of both JavaScript objects and JSON that stores key value pairs starts and ends with a curly brace. For JavaScript arrays and JSON that stores an ordered list of values, the beginning and ending characters are square brackets. The array format has all the same rules as the object format and objects are subject to a few additional rules. So let's compare a JavaScript object and its JSON representation. In JavaScript, the key doesn't require punctuation around it, but it's okay to specify it in single quotes or in double quotes. In JSON, the key must be surrounded in double quotes. So in JavaScript, I don't need quotes at all on the left, but in JSON I do. In both, the key is followed by a colon. A value in a JavaScript object can store different types of data, including strings, numbers, true false values, and even more complex nested structures like arrays and other objects. In…

Contents