Learn JSON files in 10 minutes! 📄

preview_player
Показать описание
#javascript #tutorial #json

// JSON = (JavaScript Object Notation) data-interchange format
// Used for exchanging data between a server and a web application
// JSON files {key:value} OR [value1, value2, value3]

// JSON.stringify() = converts a JS object to a JSON string.
// JSON.parse() = converts a JSON string to a JS object

00:00:00 introduction
00:00:36 create json files
00:07:10 fetch()
00:09:30 conclusion
Рекомендации по теме
Комментарии
Автор

// JSON = (JavaScript Object Notation) data-interchange format
// Used for exchanging data between a server and a web application
// JSON files {key:value} OR [value1, value2, value3]

// JSON.stringify() = converts a JS object to a JSON string.
// JSON.parse() = converts a JSON string to a JS object

// JSON.stringify()

const names = ["Spongebob", "Patrick", "Squidward", "Sandy"];
const person = {
"name": "Spongebob",
"age": 30,
"isEmployed": true,
"hobbies": ["Jellyfishing", "Karate", "Cooking"]
};
const people = [{
"name": "Spongebob",
"age": 30,
"isEmployed": true
},
{
"name": "Patrick",
"age": 34,
"isEmployed": false
},
{
"name": "Squidward",
"age": 50,
"isEmployed": true
},
{
"name": "Sandy",
"age": 27,
"isEmployed": false
}];

const jsonString = JSON.stringify(people);

console.log(jsonString);

// JSON.parse()

const jsonNames = `["Spongebob", "Patrick", "Squidward", "Sandy"]`;
const jsonPerson = `{"name": "Spongebob", "age": 30, "isEmployed": true, "hobbies": ["Jellyfishing", "Karate", "Cooking"]}`;
const jsonPeople = `[{"name": "Spongebob", "age": 30, "isEmployed": true},
{"name": "Patrick", "age": 34, "isEmployed": false},
{"name": "Squidward", "age": 50, "isEmployed": true},
{"name": "Sandy", "age": 27, "isEmployed": false}]`;

const parsedData = JSON.parse(jsonPeople);

console.log(parsedData);

// fetch()
fetch("people.json")
.then(response => response.json())
.then(values => values.forEach(value => console.log(value)))
.catch(error => console.error(error));

BroCodez
Автор

even though i have watched so many JS tutorials i still watch bro's tutorials (especially while eating) because why not

kadirertan
Автор

im so glad you're making more backend specific videos

pastori
Автор

Thanks mate for your great videos, they help a lot!

CatholicWeeb
Автор

hey bro. you plan to make node js and express js
tutorial?

ofekcohen
Автор

fetch isnt working for me at all. It is unable to read local json files.

kart_m
Автор

@BroCodez why are you creating a new javascript playlist, will the old one be deleted ?

cpu_governor
Автор

How do you write the json to the actual file though? As in changing/adding to the data in the names.json and people.json and such?

Pickle_
Автор

yo bro can you please make an advanced c++ tutorial that talks about vectors and polymorphism, encapsulation, abstraction, and the auto keyword, and also new features added to the latest version please

laperplayz
Автор

i learned a lot of things from you as a noob. now i point my friends who are learning to you channel and they really like it

mraloush
Автор

sup, u plannin next video for this one? Im learning json and ur videos help me a lot

oybekxd
Автор

Hey How about a tutorial for a low level language such as assembly language? I would also like to say that your cideos been a great help even if its just a hobby.

vxiiicv
Автор

hey Bro I started this series almost a month ago, I have been struggling with JavaScript for a long time. But you videos are gold dude!! THANKS For your explanations 🤗🤗 Which course do you thing we should try after this one? GREETINGS FROM COLOMBIA LATIN AMERICA 🤩

vallunacoder.wecodetogether
Автор

hey thanks bro, are you thinking about making more back end tutorials? i noticed you have a mySQL course but not really node js or anything else

hunin
Автор

Bro can you please make unity or Unreal engine 5 Tutorial.

sreenandhm
Автор

Week 3 of asking for bro code to make a typescript series

Swxfty_