json with open load file code example
Example 1: python json open file
import json
#reading
with open(file_name, 'r') as f:
data = json.load(f)
#writing
with open(file_name, 'w') as f:
json.dump(data, f) #use indent to make easyer to read eg. indent = 4
Example 2: read json file
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) })