Understanding JSON in JavaScript
JSON (JavaScript Object Notation) is a lightweight format for sharing data. Although it’s derived from JavaScript — it may be used with many programming languages. In this article however, we’ll be focusing on the use of JSON in JavaScript.
Where will we use JSON?
Some scenarios include:
- Data storage
- Data configuration and verification
- Generating data structures from user input
- Data transfer from client to server, server to client, and between servers
A note on AJAX — JSON is often used with AJAX, or Asynchronous JavaScript and XML. AJAX is used to transfer data without having to refresh the browser page. Later in this article, we’ll look at how to make an AJAX request to a JSON file, and output the content in the browser.
🤓 Want to stay up to date with web dev?
🚀 Want the latest news delivered right to your inbox?
🎉 Join a growing community of designers & developers!
Subscribe to my newsletter here → https://easeout.eo.page
Syntax & Structure
Most of the time you’ll encounter JSON saved in a .json
file. JSON files consist of a series of key/value pairs.