Why does json use the types it uses?

Joined
Nov 13, 2020
Messages
302
Reaction score
38
What do you mean by 'types'? JSON is a pair of information, a name and a value.
 
Joined
Jun 15, 2022
Messages
101
Reaction score
0
string/array/object/null/int/float/boolean seem to be the types it includes. Why?
 
Joined
Nov 13, 2020
Messages
302
Reaction score
38
Basic JSON looks like this: {"name":"John"},
Two strings. The only time it's not two strings is when the value is a number.
The types it allows for these strings are as you just stated and that comes from what javascript uses as objects.
You can also use dates and functions.

JSON is defined by JS objects so it's easy to pass data to JS and easy for JS to convert and use that data. It's a symbiotic relationship
Love using that word.
Hope this helps.
 
Joined
Jun 15, 2022
Messages
101
Reaction score
0
On JSON.org it says the value is of the types I mentioned. On the json wiki it (at least partly) says this is for reasons of serialization. This is where I’m interested in json. It presents a finite set (“serializable”) in terms of databasing.
 
Joined
Mar 11, 2022
Messages
227
Reaction score
32
Still your universal language???

JSON itself do not use any particular casts nor types. It's a string that comes seperated at types at the very moment it is used.
That's the same discussion we already had.
 
Joined
Jun 15, 2022
Messages
101
Reaction score
0
Trying to keep this conversation going (in a legitimate way).

So ok, my point isn't necessarily json. My point is that if you don't have a finite set at some point in a programming language you're in for it. So, at some point, there was the coincidence that json apparently supported the types I mentioned. My interest at this point is purely in the fact that those types represent a finite set that is also turing complete.

Why is that not a better idea than, say, something like php that also has the types "resource" and "resource (closed)"?
 
Joined
Sep 4, 2022
Messages
128
Reaction score
16
As Js can handle lot of types in the same bunch ( like complex arrays do : type / function / object / strings ),

json comes here, and is so compliant with Js and DOM

serializable means that a json pattern could be build :
- with multi-dimensionnal array grounding a hierarchy for Datas constraints and organisation.
- the pairs : key:value
- complex types in : function / object / single var all types

In the other languages, to stock all data types : It's "variant" / "object" types.

but Js and Json in a web browser are loaded, before all as "a big string" ( with its File from server ),
then in the DOM as part of it.
then the Js engine parse and execute all in the dom.

if you're interested by complex arrays and lots of types in,
read the jquery code API, you'll see it's only JS.

lot of API for web browser are JS at high skill. It's all objects and complex arrays.


JSON appears with the NOSQL database after year 2000' ( born before ~1997 ),
because its purpose is a container for all datas in a row of a db or file.
It's 'blob'
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top