how to open json file code example
Example 1: open json file python
import json
with open('data.txt') as json_file:
data = json.load(json_file)
Example 2: open json file r
# Load the package required to read JSON files.
library("rjson")
# Give the input file name to the function.
result <- fromJSON(file = "input.json")
# Print the result.
print(result)
Example 3: 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) })