Python membaca file json
import json
with open('path_to_file/person.json') as f:
data = json.load(f)
print(data)
MzanziLegend
import json
with open('path_to_file/person.json') as f:
data = json.load(f)
print(data)
const fs = require('fs');
let rawdata = fs.readFileSync('student.json');
let student = JSON.parse(rawdata);
console.log(student);
fetch("file.json")
.then(Response => Response.json())
.then(data => {
console.log(data);
// or whatever you wanna do with the data
});
const fs = require('fs');
fs.readFile('./customer.json', 'utf8', (err, jsonString) => {
if (err) {
console.log("File read failed:", err)
return
}
console.log('File data:', jsonString)
})
fs.readFile(filePath, function (error, content) {
var data = JSON.parse(content);
console.log(data.collection.length);
});
<script type="text/javascript" src="data.json"></script>
<script type="text/javascript" src="javascrip.js"></script>