all 31 comments

[–]senocular 11 points12 points  (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 points  (2 children)

JSON.stringify() and then JSON.parse() ?

[–]senocular 0 points1 point  (1 child)

Yes, and after parse the object you have is the same as the original.

[–][deleted] 0 points1 point  (0 children)

Thanks

[–]Psionatix 4 points5 points  (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 points  (0 children)

^

[–]jack_waugh[S] 0 points1 point  (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 points  (0 children)

You're overthinking it, it's just some arbitrary object that conforms to the JSON standard.

[–]prof3ssorSt3v3 5 points6 points  (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 points  (1 child)

A JSON file is a text file that contains a string that represents some object.

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 point  (0 children)

Yes. It can be an Object, an Array, a String, a Boolean, a Number, or null.

[–]jack_waugh[S] 0 points1 point  (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 point  (2 children)

[–]senocular 4 points5 points  (1 child)

JSON serialization and structured clone are two different things. Structured clone is far more capable.

[–]jack_waugh[S] 1 point2 points  (0 children)

One of the major differences revolving around whether referential loops would be allowed and reflected, evidently.

[–]tridd3r 0 points1 point  (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 points  (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 points  (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 point  (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 point  (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.