Task

File data.json

[
    {
        "id": 1,
        "name": "Andi",
        "score": 95
    },
    {
        "id": 2,
        "name": "Rajif",
        "score": 80
    }
]

file index.js

const fs = require('fs')
let data = fs. readFileSync('./data.json', 'utf8')

let parsedData = JSON.parse(data)
//console.log(parsedData)
console.log("List Student")
parsedData.forEach(data => {
    console.log(`${data.id}. ${data.name}, ${data.score}`)
})

// hasil
//1. Andi, 95
//2. Rajif, 80

Penjelasan singkat

  • JSON merupakan format data paling populer dalam Application Programming Interface (API)

  • Struktur JSON dipakai juga untuk notasi struktur data pada NoSQL(contoh: MongoDB)

Last updated

Was this helpful?