Whenever someone here says "I have a JSON object", people complain (rightly) that "There's no such thing as a JSON object!" But...
What do you call the class of data structures that could be represented by JSON?
It's something like "the finite transitive closure of Map, List, Number, String, and Boolean" -- that is, omitting things like functions and the fancier structures like sets and queues. The category is useful. Obviously, everything done in JSON uses it. CouchDB (and I think the other document-oriented databases) use it. Most acyclic data structures are contained in it.
But what it is called?
It is a common mistake to call a JSON object literal "a JSON object". JSON cannot be an object. JSON is a string format. The data is only JSON when it is in a string format. When it is converted to a JavaScript variable, it becomes a JavaScript object.
A JSON object contains zero, one, or more key-value pairs, also called properties. The object is surrounded by curly braces {} . Every key-value pair is separated by a comma. The order of the key-value pair is irrelevant.
JSON Object Example A JSON object contains data in the form of key/value pair. The keys are strings and the values are the JSON types. Keys and values are separated by colon. Each entry (key/value pair) is separated by comma.
The two primary parts that make up JSON are keys and values. Together they make a key/value pair. Key: A key is always a string enclosed in quotation marks. Value: A value can be a string, number, boolean expression, array, or object.
JSON is simply a notation that happens to easily translate to Javascript objects. When JSON is reified in Javascript (evaluated), it turns into a Javascript object/associative array (depending on the JSON representing it).
I think the class of data structures that can be represented by JSON are just that: "data structures". For example, you could represent binary trees in JSON, or even lists and maps; these are specific data-structures in their own right, and the overall term for them is just "data structure".
Assuming that JSON could only represent one specific type of data structure (for example, only trees), then we could call the class of objects represented by JSON as just "trees". But JSON does more than that; it can represent different kinds of data structures, which is why it's probably just best to say "I have this JSON here and it represents the so-and-so data-structure".
I guess if you really boil it down, JSON represents a data-structure that is either a sequence or a structure that contains name-value pairs, where the values can be primitives (int
s, string
s, float
s, boolean
s, null
s, undefined
s), or name-value pairs or sequences.
Thinking about it a bit more, asking for the name of the class of data structure that could be represented by JSON is like asking for the name of the class of data structures that could be represented by XML. Both are abstract notations that can be reified into actual objects.
TL; DR; Just call it an object, or by its actual data-structure name. It's just like saying "XML Object". There's no general name for the class of structures represented by XML. XML can represent an object, just like JSON can represent an object.
You could call them "JSON-compatible" or "JSON-serializable" maybe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With