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
Jochem3w 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
FakerOP3w ago
yep I see, basically all JSON is all about is about data transmission ?
ἔρως
ἔρως3w 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
FakerOP3w ago
yep I see, so its main use is to store data (on localStorage for e.g) or to transmit data ?
Jochem
Jochem3w ago
either or it's an unimportant distinction, it's used for both
ἔρως
ἔρως3w 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
Jochem3w ago
it's used extensively in webdev for storage too
ἔρως
ἔρως3w ago
an example of data transmission is an api that sends and receives json
Jochem
Jochem3w 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
ἔρως
ἔρως3w ago
i use it a lot for localstorage and apis
Faker
FakerOP3w 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?
ἔρως
ἔρως3w ago
small? im not sure
Faker
FakerOP3w ago
any project then? I can have a look :c
Jochem
Jochem3w ago
todo list always a todo list
ἔρως
ἔρως3w ago
thats a good one
Faker
FakerOP3w ago
Hmm what should I do?
Jochem
Jochem3w 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
FakerOP3w ago
Ok got it, I will try it
Jochem
Jochem3w ago
don't worry about the layout either, just use an unstyled UL and input fields to start with
ἔρως
ἔρως3w ago
and checkboxes you dont need to make it fancy
Faker
FakerOP3w ago
Okep
Lukas Balz
Lukas Balz3w 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
Want results from more Discord servers?
Add your server