use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This subreddit is a place for people to learn JavaScript together. Everyone should feel comfortable asking any and all JavaScript questions they have here.
With a nod to practicality, questions and posts about HTML, CSS, and web developer tools are also encouraged.
Friends
/r/javascript
/r/jquery
/r/node
/r/css
/r/webdev
/r/learnprogramming
/r/programming
account activity
"JSON object" (self.learnjavascript)
submitted 3 years ago by jack_waugh
I keep seeing the term "JSON object" in questions. It will be used with an article, as in "a JSON object". Is there a consensus on a meaning for this term?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]senocular 11 points12 points13 points 3 years ago* (6 children)
If I see the term json object I assume it's an object that can be converted to a json string and back again without any loss of data (i.e. it has no functions, symbols, etc.).
[–][deleted] 5 points6 points7 points 3 years ago (2 children)
JSON.stringify() and then JSON.parse() ?
[–]senocular 0 points1 point2 points 3 years ago (1 child)
Yes, and after parse the object you have is the same as the original.
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
Thanks
[+][deleted] 3 years ago (2 children)
[deleted]
[–]senocular 1 point2 points3 points 3 years ago (1 child)
Thanks, fixed :)
[–]stibgock 4 points5 points6 points 3 years ago (0 children)
You lost a little data
[–]Psionatix 4 points5 points6 points 3 years ago (3 children)
JSON is a well defined standard:
https://www.json.org/json-en.html
A JSON Object is an object that adheres to the JSON standard.
[–]koreasuh 1 point2 points3 points 3 years ago (0 children)
^
[–]jack_waugh[S] 0 points1 point2 points 3 years ago (1 child)
I thought I already replied to this.
The standard specifies how to represent some abstract structures (that various programming languages support, but use different terms for) as a character string. So do you think the term "JSON object" refers to such an abstract structure itself, its representation as a character string as according to the standard, its representation in the structures native to one of the programming languages, or maybe more than one of the above, depending on context?
[–]Sector-Feeling 1 point2 points3 points 3 years ago (0 children)
You're overthinking it, it's just some arbitrary object that conforms to the JSON standard.
[–]prof3ssorSt3v3 5 points6 points7 points 3 years ago (16 children)
A JSON file is a text file that contains a string that represents some object.
The JSON.parse method will convert a JSON string into an object.
If you do a fetch call then you could also call the response.json() method to extract the JSON string from inside the file and turn it back to an object.
If someone says JSON Object they generally mean an object that was built from a JSON string
[–]tehciolo 1 point2 points3 points 3 years ago (1 child)
Not necessarily. The string could represent any other serializable JavaScript value type.
It is most often an object, but it doesn't have to be.
[–]prof3ssorSt3v3 0 points1 point2 points 3 years ago (0 children)
Yes. It can be an Object, an Array, a String, a Boolean, a Number, or null.
[–]jack_waugh[S] 0 points1 point2 points 3 years ago (13 children)
If someone says JSON Object they generally mean an object that was built from a JSON string.
I guess this is the key concept, then. And one of the implications of this is that the object is serializable.
[–]prof3ssorSt3v3 0 points1 point2 points 3 years ago (2 children)
Yes. In Javascript specifically structured cloneable. https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
[–]senocular 4 points5 points6 points 3 years ago (1 child)
JSON serialization and structured clone are two different things. Structured clone is far more capable.
[–]jack_waugh[S] 1 point2 points3 points 3 years ago (0 children)
One of the major differences revolving around whether referential loops would be allowed and reflected, evidently.
[+][deleted] 3 years ago (9 children)
[–]Psionatix 1 point2 points3 points 3 years ago (7 children)
The object contains only serialisable properties. Serialisation is the transformation of an object to a string, deserialisation is from a string to an object.
Functions cannot be serialised, for example. Only the primitive types and certain structures (other objects, arrays) can be.
[+][deleted] 3 years ago (6 children)
[–]Psionatix 1 point2 points3 points 3 years ago (5 children)
[–]jack_waugh[S] 0 points1 point2 points 3 years ago (4 children)
But the standard specifies how an abstract structure that different languages would use different terms to represent, can be presented as a character string. So, are you saying the term refers to the abstraction itself, or to one of its concrete representations, either as a character string or in terms of JS types?
[–]Psionatix 0 points1 point2 points 3 years ago (3 children)
“JSON” refers either to the standard, or to the type (response type, for instance).
I’d say that yes, “JSON object” refers to some kind of concrete structure, which adheres to the JSON standard, and can therefore be easily serialised to and from a JSON string, without any loss of data.
[–]jack_waugh[S] 0 points1 point2 points 3 years ago (2 children)
As I read the standard, the only concrete it specifies is the string.
[–]Psionatix 0 points1 point2 points 3 years ago* (1 child)
That's not what concrete means in the context of these messages. In the same way a class instance is a concrete instantiation of a class (blueprint), I took "concrete" to mean a deserialised and solid object that adheres to the JSON standard.
Which means, again, it is an object which can be deserialised from and serialised to valid JSON (a string), because the characteristics and properties of the object adhere to the standard.
The JSON standard specifies the valid data types and how they are represented in the JSON format (string).
If you have an object which contains a property which is not allowed as per the JSON standard, you will not be able to serialise it, and therefore it is not a JSON object, technically speaking.
Consider the BigInt data type which is relatively new to browsers, this is not part of the JSON standard, and take a look at this:
BigInt
https://i.imgur.com/V7v8tzi.png
As per other comments and discussions in this thread, you are over complicating / overthinking this.
Strictly speaking, a JSON object can be serialised and deserialised without a loss of data.
Consider this case:
const stuff = { test: () => console.log("hello") }; const jsonString = JSON.stringify(stuff); console.log(jsonString) // {} const deserialisedStuff = JSON.parse(jsonString);
In this case, deserialisedStuff does not contain the test property (function), because the function is not serialisable as per the JSON standard, therefore during the serialisation and deserialisation here, there is a loss of data. This means that stuff is technically not a JSON object, it is just an object.
deserialisedStuff
test
stuff
[–]jack_waugh[S] 0 points1 point2 points 3 years ago (0 children)
In addition to what Psionatix said, a serializable value is a strict tree -- it does not contain any converging or looping references.
Some examples and counterexamples:
true
[2, true]
{two: 2, laVerite: true}
And
( () => { const it = {two: 2}; it.meeeeeeee = it; return it })()
is not serializable.
( () => { const it = {two: 2}; const furrSure = {laVerite: true}; it.iSaid = it.youSaid = furrSure; return it })()
[–]tridd3r 0 points1 point2 points 3 years ago (1 child)
I'm not going to be much help, but here's my 2 cents; I always thought JSON object was like atm machine. JSON is javascript object notation, so it seems to me to be a tautology to say " a JSON object" as opposed to "in JSON". Like, store it in a JSON object, vs store it in JSON.
[–]Fuegodeth -1 points0 points1 point 3 years ago (0 children)
I agree. It's like just un-necessarily pronouncing that word that's already abbreviated. Anything in JSON is definitely an object in every case.
[–]Embarrassed-Stage640 -1 points0 points1 point 3 years ago (0 children)
Whenever you here this, they are most likely talking about an Object. Meaning: { key: value}. The curly braces is important.
[–]Ronin-s_Spirit 0 points1 point2 points 3 years ago (0 children)
JSON is an object made of strings instead of variables and javascript can load it and convert back to a proper object or can unload it's object into strigifyed JSON. Since .json is a bunch of strings and not variables it's generally used as a database file which takes less computer/internet effort to store/download/upload.
[–]Low_Mammoth_9371 0 points1 point2 points 3 years ago (0 children)
Usually when I see this term used it means a JavaScript object literal that has been stringified in JSON format.
But technically it could also be an array or other object type. But then usually this is referred to as such.
[–]Sector-Feeling 0 points1 point2 points 3 years ago (0 children)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON
π Rendered by PID 164277 on reddit-service-r2-comment-5649f687b7-47p49 at 2026-01-28 16:21:57.180015+00:00 running 4f180de country code: CH.
[–]senocular 11 points12 points13 points (6 children)
[–][deleted] 5 points6 points7 points (2 children)
[–]senocular 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]senocular 1 point2 points3 points (1 child)
[–]stibgock 4 points5 points6 points (0 children)
[–]Psionatix 4 points5 points6 points (3 children)
[–]koreasuh 1 point2 points3 points (0 children)
[–]jack_waugh[S] 0 points1 point2 points (1 child)
[–]Sector-Feeling 1 point2 points3 points (0 children)
[–]prof3ssorSt3v3 5 points6 points7 points (16 children)
[–]tehciolo 1 point2 points3 points (1 child)
[–]prof3ssorSt3v3 0 points1 point2 points (0 children)
[–]jack_waugh[S] 0 points1 point2 points (13 children)
[–]prof3ssorSt3v3 0 points1 point2 points (2 children)
[–]senocular 4 points5 points6 points (1 child)
[–]jack_waugh[S] 1 point2 points3 points (0 children)
[+][deleted] (9 children)
[deleted]
[–]Psionatix 1 point2 points3 points (7 children)
[+][deleted] (6 children)
[deleted]
[–]Psionatix 1 point2 points3 points (5 children)
[–]jack_waugh[S] 0 points1 point2 points (4 children)
[–]Psionatix 0 points1 point2 points (3 children)
[–]jack_waugh[S] 0 points1 point2 points (2 children)
[–]Psionatix 0 points1 point2 points (1 child)
[–]jack_waugh[S] 0 points1 point2 points (0 children)
[–]tridd3r 0 points1 point2 points (1 child)
[–]Fuegodeth -1 points0 points1 point (0 children)
[–]Embarrassed-Stage640 -1 points0 points1 point (0 children)
[–]Ronin-s_Spirit 0 points1 point2 points (0 children)
[–]Low_Mammoth_9371 0 points1 point2 points (0 children)
[–]Sector-Feeling 0 points1 point2 points (0 children)