Idk know if Im needed here but still I will try.
Note: Everything is based on my current knowledge so pardon me if this is going wrong anywhere, and please correct me for the community to keep growing
My answer actually contains fundamentals as to how they work and why? So if u needed that then here it is-
First of all there are 2 types of JSON:
- json data
- json string
json data as we know is exactly like dictionary in python. That means they work on hash maps.
But we convert it to string before transferring the json data to somewhere else through the networks.
So it will look something like this:
json_data = {"data":"This will original"}
After conversion it will look like this : '{"data":"This will original"}'
You will notice that the json_data has been converted to string and is now being written within quotation.
You can also check the data type in python through, type(json_data)
.
The reason why we do this is because the cost of string is much less than that of the actual objects. And this is much easier to do.
So now when this data will be transmitted to some other language(like python) then they will receive a json string. And now they have to parse these to objects to be able to use the data inside it. Otherwise they are just simple strings.
So now u need to convert it back to json data. And in python json data or java script object is equivalent to dictionary. That's why we convert the string to dict.
Other languages must be having different names for their dictionary type data structure then it will convert the string to those type of data structure.
In python to be able to convert from string to json and json to string. That class must have json serializers to know what and how to convert.
Hope this helps even if little. And if there are any doubts I'll be happy to answer.