Trying to understand what JSON is and why is it important

Hello guys, sorry to disturb you all; I'm confuse about how JSON works and why is it important, can someone confirm whether the following are correct and what you guys can add to it please: 1. JSON is a data structure use to transmit data (e.g. from server to client). 2. In order to retrieve data from a JSON format, we must use the JSON.parse() method 3. In order to format an object into a JSON format, we must use the JSON.stringify() method That's all I understood 😭 , it's too unclear in my head... is there a small project I can build just to get the idea of what is JSON, how to work with it and its importance please
22 Replies
Jochem
Jochem3mo ago
it's correct! JSON is a way to translate (some) data into string format so it can be transmitted and stored easily in a way that's designed to be interoperable between many systems storing a string is easy, storing a more complex data structure like an array or object is hard, so with JSON you turn that complex data structure into a string and save it to disk or transmit it over the internet
Faker
FakerOP3mo ago
yep I see, basically all JSON is all about is about data transmission ?
ἔρως
ἔρως3mo ago
and the structure is human readable, which allows you to debug or understand it without any specialized software to parse it and storage it's a data format very strongly based in javascript objects
Faker
FakerOP3mo ago
yep I see, so its main use is to store data (on localStorage for e.g) or to transmit data ?
Jochem
Jochem3mo ago
either or it's an unimportant distinction, it's used for both
ἔρως
ἔρως3mo ago
one example of data storage is minecraft it uses json very extensively the java version has been slowly moving into a data-driven model, where everything is in json files
Jochem
Jochem3mo ago
it's used extensively in webdev for storage too
ἔρως
ἔρως3mo ago
an example of data transmission is an api that sends and receives json
Jochem
Jochem3mo ago
I use it a lot to store stuff in localStorage, sqlite and most other databases support it directly too, and mongodb/other document databases use it exclusively
ἔρως
ἔρως3mo ago
i use it a lot for localstorage and apis
Faker
FakerOP3mo ago
Yep, I have a clearer overview now, ty !!! Is there a small project or something like that I can build use to see its practical usage?
ἔρως
ἔρως3mo ago
small? im not sure
Faker
FakerOP3mo ago
any project then? I can have a look :c
Jochem
Jochem3mo ago
todo list always a todo list
ἔρως
ἔρως3mo ago
thats a good one
Faker
FakerOP3mo ago
Hmm what should I do?
Jochem
Jochem3mo ago
people poopoo the todo list, but the reason it's so popular is that it's easy to go from a basic implementation to something very complicated store the data in localstorage using json
Faker
FakerOP3mo ago
Ok got it, I will try it
Jochem
Jochem3mo ago
don't worry about the layout either, just use an unstyled UL and input fields to start with
ἔρως
ἔρως3mo ago
and checkboxes you dont need to make it fancy
Faker
FakerOP3mo ago
Okep
Lukas Balz
Lukas Balz3mo ago
Take a look at the pokeapi 2.0 and try to understand it and build a simple Pokédex which you easy can build bigger and bigger with more and more features when you learn more or use new methods u learned, like a search bar using filter functions or the map functions, at the end it depends on ur current knowledge but for me it was a very good project to learn json and a few things about it

Did you find this page helpful?