Introduction to JSON parsing
Hello! This is Nakiri Json db this website have json files that you can use to practice your API that you will use for your projects
This is an example code that you can use to fetch a JSON body
(async () =>{
fetch("https://sandbox.nakiri.space/data/people.json")
.then(response => response.json())
.then(data => {
data.forEach(user => {
console.log("Name :" + user.name)
console.log("Age :" + user.age)
})
})
.catch(error => {
console.error("Error fetching data:", error);
});
})();
and this is an example output
Name :John Doe
Age :28
Name :Jane Smith
Age :34
Name :Alice Johnson
Age :22
Name :Bob Brown
Age :45
Name :Charlie Davis
Age :30
.....
Here is the different types of JSON structure you can use to practice parsing JSON
People JSON Structure - Level: Medium
Top-Level Keys
- id
- name
- age
- address
- quote
- details (nested objects)
Keys inside details
- hobbies (array)
- education (nested object)
Keys inside education
- degree
- major
This section shows you the look of a JSON Structure inside a file
{
"id": "1a2b3c",
"name": "John Doe",
"age": 28,
"address": "123 Main St, Springfield, IL",
"email": "johndoe@example.com",
"quote": "The only limit is your imagination.",
"details": {
"hobbies": ["reading", "hiking", "coding"],
"education": {
"degree": "Bachelor of Science",
"major": "Computer Science"
}
}
}