🌐
W3Schools
w3schools.com › js › js_json.asp
JavaScript JSON
JS Examples JS HTML DOM JS HTML ... JS Interview Prep JS Bootcamp JS Certificate JS Reference ... JSON stands for JavaScript Object Notation. JSON is a plain text format for storing and transporting data....
🌐
Reddit
reddit.com › r/learnprogramming › what is json and what does it have to do with javascript?
r/learnprogramming on Reddit: What is JSON and what does it have to do with Javascript?
March 31, 2022 -

Hi! I'm looking to dive back into Javascript after a 10+ year hiatus (learned some during college) in order to build out a basic piece of software using a WebSocket for a lighting control system. I notice that most of it can be done with Javascript, but every now and then there are JSON calls. Looking at JSON's wiki page, I notice it's an acronym "JavaScript Object Notation" so obviously has lots to do with Javascript, but apparently it's also " a language-independent data format." (whatever that means).

Any indications if I'll need to be proficient with JSON to work with the WebSocket? If so, any recommendations for resources to get started? Thank you!

Top answer
1 of 5
4
I notice it's an acronym "JavaScript Object Notation" so obviously has lots to do with Javascript, but apparently it's also " a language-independent data format." (whatever that means). It means that the syntax of JSON is based on the way you construct objects in JavaScript, but it exists independently from JS. It's a data exchange format. Similar to XML. It's just a way to use text to structure data. JSON isn't a language that really requires proficiency. For one thing, it's not a programming language; it doesn't convey logic. It's just data. And it's quite simple. There are only four data types in JSON: string, number, array, and object. Whether or not you have to be proficient with it to use WebSockets? Technically they aren't directly related. But JSON is an extremely common format to pass data over WebSockets (as well as HTTP endpoints as well).
2 of 5
3
JSON came from JavaScript but it has nothing to do with JavaScript anymore. Have you ever used XML before? JSON is basically used for most of the same sorts of things that XML was used for. JSON is basically a handy standard format to use when sending structured data from one program to another, or when saving data to a file, or something like that. That's it. By using JSON instead of making up your own format, you make it easy for anyone to parse. JSON specifies the syntax, but not the semantics. You can decide whatever data you want to put in it. Let's say you wanted to save a list of names to a file. Using JSON, you could do it like this: ["Candace", "Maya", "Ken", "Tobias"] It looks just like you're defining an array in JavaScript, and that's the idea. Let's say you needed names and ages. You could do it like this: [ { "name": "Candace", "age": 44 }, { "name": "Maya", "age": 19 }, { "name": "Ken", "age": 35 }, { "name": "Tobias", "age": 27 } ] Should you learn JSON? Yes, but it's really not that complicated. You could read the documentation in an hour and get the hang of reading and writing JSON in your favorite language in less than a day. Sure, there's more complexity to it sometimes. If you're working with really large amounts of data, people have created all sorts of tools for manipulating large JSON files, or doing queries or transformations. If you ever have a need for those, you can learn them.
Discussions

What is JSON and what is it used for? - Stack Overflow
Explore Stack Internal ... I've looked on Wikipedia, googled it, and read the official documentation, but I still haven't got to the point where I really understand what JSON is, and why I'd use it. I have been building applications using PHP, MySQL and JavaScript / HTML for a while, and if ... More on stackoverflow.com
🌐 stackoverflow.com
Can someone please explain JSON to me?
JSON is derived from JavaScrtipt (JavaScript Object Notation) and is just the format using key value pairs. Values can be booleans, strings, numbers, arrays or objects. That's all it is. More on reddit.com
🌐 r/learnjavascript
88
56
November 24, 2023
How to check if JavaScript object is JSON - Stack Overflow
JSON encoded resource is not an object. It is a string. Only after you decode it or in Javascript JSON.parse() it does the JSON resource become an object. Therefore if you test a resource coming from a server to see if it is JSON, it is best to check first for String, then if is a not a More on stackoverflow.com
🌐 stackoverflow.com
What is JSON and what does it have to do with Javascript?
I notice it's an acronym "JavaScript Object Notation" so obviously has lots to do with Javascript, but apparently it's also " a language-independent data format." (whatever that means). It means that the syntax of JSON is based on the way you construct objects in JavaScript, but it exists independently from JS. It's a data exchange format. Similar to XML. It's just a way to use text to structure data. JSON isn't a language that really requires proficiency. For one thing, it's not a programming language; it doesn't convey logic. It's just data. And it's quite simple. There are only four data types in JSON: string, number, array, and object. Whether or not you have to be proficient with it to use WebSockets? Technically they aren't directly related. But JSON is an extremely common format to pass data over WebSockets (as well as HTTP endpoints as well). More on reddit.com
🌐 r/learnprogramming
11
0
March 31, 2022
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Scripting › JSON
Working with JSON - Learn web development | MDN
JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax. It is commonly used for transmitting data in web applications (e.g., sending some data from the server to the client, so it can be displayed on a web page, or ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-json
JavaScript JSON - GeeksforGeeks
July 11, 2025 - JSON (JavaScript Object Notation) is a lightweight data format for storing and exchanging data. It is widely used to send data between a server and a client. JSON is simple, language-independent, and easy to understand.
text-based open standard designed for human-readable data interchange
whitespace
object
combox respuesta json
JSON (JavaScript Object Notation, pronounced /ˈdʒeɪsən/ or /ˈdʒeɪˌsɒn/) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of name–value pairs … Wikipedia
Factsheet
JavaScript Object Notation
Filename extension .json
Internet media type application/json
Factsheet
JavaScript Object Notation
Filename extension .json
Internet media type application/json
🌐
Wikipedia
en.wikipedia.org › wiki › JSON
JSON - Wikipedia
March 6, 2005 - JSON (JavaScript Object Notation, ... is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of name–value pairs and arrays (or other serializable values)....
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › JSON
JSON - JavaScript | MDN
The JSON namespace object contains static methods for parsing values from and converting values to JavaScript Object Notation (JSON). Unlike most global objects, JSON is not a constructor. You cannot use it with the new operator or invoke the JSON object as a function.
🌐
Oracle
oracle.com › ai database
What is JSON?
April 4, 2024 - JSON (JavaScript Object Notation) is a text-based format for storing and exchanging data in a way that’s both human-readable and machine-parsable. As a result, JSON is relatively easy to learn and to troubleshoot.
Find elsewhere
Top answer
1 of 15
679

JSON (JavaScript Object Notation) is a lightweight format that is used for data interchanging. It is based on a subset of JavaScript language (the way objects are built in JavaScript). As stated in the MDN, some JavaScript is not JSON, and some JSON is not JavaScript.

An example of where this is used is web services responses. In the 'old' days, web services used XML as their primary data format for transmitting back data, but since JSON appeared (The JSON format is specified in RFC 4627 by Douglas Crockford), it has been the preferred format because it is much more lightweight

You can find a lot more info on the official JSON web site.

JSON is built on two structures:

  • A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
  • An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

JSON Structure













Here is an example of JSON data:

{
     "firstName": "John",
     "lastName": "Smith",
     "address": {
         "streetAddress": "21 2nd Street",
         "city": "New York",
         "state": "NY",
         "postalCode": 10021
     },
     "phoneNumbers": [
         "212 555-1234",
         "646 555-4567"
     ]
 }

JSON in JavaScript

JSON (in JavaScript) is a string!

People often assume all JavaScript objects are JSON and that JSON is a JavaScript object. This is incorrect.

In JavaScript, var x = {x:y} is not JSON, this is a JavaScript object. The two are not the same thing. The JSON equivalent (represented in the JavaScript language) would be var x = '{"x":"y"}'. x is an object of type string not an object in its own right. To turn this into a fully fledged JavaScript object you must first parse it, var x = JSON.parse('{"x":"y"}');, x is now an object but this is not JSON anymore.

See JavaScript object vs. JSON


When working with JSON and JavaScript, you may be tempted to use the eval function to evaluate the result returned in the callback, but this is not suggested since there are two characters (U+2028 & U+2029) valid in JSON but not in JavaScript (read more of this here).

Therefore, one must always try to use Crockford's script that checks for a valid JSON before evaluating it. Link to the script explanation is found here and here is a direct link to the JavaScript file. Every major browser nowadays has its own implementation for this.

Example on how to use the JSON parser (with the JSON from the above code snippet):

// The callback function that will be executed once data is received from the server
var callback = function (result) {
    var johnny = JSON.parse(result);
    // Now, the variable 'johnny' is an object that contains all of the properties
    //from the above code snippet (the JSON example)
    alert(johnny.firstName + ' ' + johnny.lastName); // Will alert 'John Smith'
};

The JSON parser also offers another very useful method, stringify. This method accepts a JavaScript object as a parameter, and outputs back a string with JSON format. This is useful for when you want to send data back to the server:

var anObject = {name: "Andreas", surname : "Grech", age : 20};
var jsonFormat = JSON.stringify(anObject);
// The above method will output this: {"name":"Andreas","surname":"Grech","age":20}

The above two methods (parse and stringify) also take a second parameter, which is a function that will be called for every key and value at every level of the final result, and each value will be replaced by result of your inputted function. (More on this here)

Btw, for all of you out there who think JSON is just for JavaScript, check out this post that explains and confirms otherwise.


References

  • JSON.org
  • Wikipedia
  • Json in 3 minutes (Thanks mson)
  • Using JSON with Yahoo! Web Services (Thanks gljivar)
  • JSON to CSV Converter
  • Alternative JSON to CSV Converter
  • JSON Lint (JSON validator)
2 of 15
81

The Concept Explained - No Code or Technical Jargon

What is JSON? – How I explained it to my wifeTM

Me: “It’s basically a way of communicating with someone in writing....but with very specific rules.

Wife: yeah....?

Me: In prosaic English, the rules are pretty loose: just like with cage fighting. Not so with JSON. There are many ways of describing something:

• Example 1: Our family has 4 people: You, me and 2 kids.

• Example 2: Our family: you, me, kid1 and kid2.

• Example 3: Family: [ you, me, kid1, kid2]

• Example 4: we got 4 people in our family: mum, dad, kid1 and kid2.

Wife: Why don’t they just use plain English instead?

Me: They would, but remember we’re dealing with computers. A computer is stupid and is not going to be able to understand sentences. So we gotta be really specific when computers are involved otherwise they get confused. Furthermore, JSON is a fairly efficient way of communicating, so most of the irrelevant stuff is cut out, which is pretty hand. If you wanted to communicate our family, to a computer, one way you could do so is like this:

{
    "Family": ["Me", "Wife", "Kid1", "Kid2"] 
}

……and that is basically JSON. But remember, you MUST obey the JSON grammar rules. If you break those rules, then a computer simply will not understand (i.e. parse) what you are writing.

Wife: So how do I write in Json?

A good way would be to use a json serialiser - which is a library which does the heavy lifting for you.

Summary

JSON is basically a way of communicating data to someone, with very, very specific rules. Using Key Value Pairs and Arrays. This is the concept explained, at this point it is worth reading the specific rules above.

🌐
JSON
json.org
JSON
ECMA-404 The JSON Data Interchange Standard. JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language Standard ECMA-262 3rd ...
🌐
IBM
ibm.com › docs › en › baw › 23.0.x
JavaScript Object Notation (JSON) format
The JavaScript Object Notation (JSON) format is discussed.
🌐
Programiz
programiz.com › javascript › json
JavaScript and JSON (with Examples)
... Created with over a decade of experience and thousands of feedback. ... Try Programiz PRO! ... Become a certified JavaScript programmer. Try Programiz PRO! ... JSON stands for Javascript Object Notation. JSON is a text-based data format that is used to store and transfer data.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-work-with-json-in-javascript
How To Work with JSON in JavaScript | DigitalOcean
August 26, 2021 - This tutorial will provide you with an introduction to working with JSON in JavaScript. To make the most use of this introduction, you should have some familiarity with the JavaScript programming language. JSON’s format is derived from JavaScript object syntax, but it is entirely text-based.
🌐
ITU Online
ituonline.com › itu online › tech terms definitions › what is json (javascript object notation)?
What Is JSON (JavaScript Object Notation)? - ITU Online IT Training
June 1, 2024 - JSON (JavaScript Object Notation) is a text-based format for representing structured data based on JavaScript object syntax. Despite its origins in JavaScript, JSON is language-independent, with parsers available for virtually every programming language.
🌐
Appsmith
community.appsmith.com › content › blog › javascript-objects-vs-json-explained-simply
Javascript Objects Vs JSON: Explained Simply | Appsmith Community Portal
March 26, 2024 - JSON (Javascript Object Notation) is a way to write down information that computers and humans can understand. It's really good for sending data from one place to another, like from your computer to a website, because it's straightforward and ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › json
JSON Tutorial - GeeksforGeeks
January 13, 2026 - JSON (JavaScript Object Notation) is a widely-used, lightweight data format for representing structured data. Used Extensively : Used in APIs, configuration files, and data exchange between servers and clients.
🌐
Built In
builtin.com › software-engineering-perspectives › json
What Is JSON (JavaScript Object Notation)? | Built In
Summary: JSON (JavaScript Object Notation) is a language-independent, human-readable format used to store and transfer data. Commonly used in RESTful APIs, it supports key-value pairs, arrays and various data types and is compatible with many ...
🌐
Koombea
koombea.com › home › json vs. javascript: what is the difference?
JSON Vs. JavaScript: What is the Difference?
November 26, 2024 - JSON data is structured in two basic ways: a key/value pair or a collection of such pairs, or an ordered list. JSON allows six different types of data to be stored or transported, including: ... As you can see, JavaScript and JSON are two completely different things.
🌐
OpenReplay
blog.openreplay.com › how-to-read-and-write-json-in-javascript
How to Read and Write JSON in JavaScript
JSON stands for JavaScript Object Notation, and although it is clearly related to JavaScript, the two are not the same. Specifically, JSON is a data exchange format based on a subset of JavaScript syntax.
🌐
Reddit
reddit.com › r/learnjavascript › can someone please explain json to me?
r/learnjavascript on Reddit: Can someone please explain JSON to me?
November 24, 2023 -

I've never worked with any DB or back-end, etc stuff, but I am in need of some sort of data storage. I'm working on a javascript application that will only be run on my pc, offline, and I need to be able to save information. I don't want to rely on localStorage because if the browser history is wiped then all the data goes with it.

While searching for a way to collect and store info, I read about JSON, and it sounded like what I was looking for--and yet I've spent the last 4 hours watching tutorials and so far all I know about it is it's fching JS. I sat through a 12 minute video where all the guy did was write out an object in json and then copy and paste into a js file and said "now you know how to use json in all your future projects" 🙄 like what in ACTUAL fk. You could have just WROTE that in js. What's the point of JSON? Everything I've seen or read is practically just the same as this video.

DOES json collect and store data?

Like, if I put an input form in my app, and type a name and hit submit, can I make that Input hardcode into the json file to be saved forevermore and called upon when I needed in this app? Because that's what I need. Any explanation or help on this would be GREATLY appreciated.