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