read json data from file

JavaScript
import json

with open('path_to_file/person.json') as f:
  data = json.load(f)

print(data)import json

with open('data.txt') as json_file:
    data = json.load(json_file)>>> jstr = json.dumps(data, ensure_ascii=False, indent=4)
>>> print(jstr)
{
    "item": "Beer",
    "cost": "£4.00"
}
 
// consider your file data is something like json string but aving parse issue 
//that means some additional char is there 
fs.readFile(ROLES_FILE, "utf8", (err, data) => {
      if (err) {
        res.status(403).json({});
      }
      const [localScope, action] = scope.split(".");
      const mapper = JSON.parse(data.toString("utf8").replace(/^\uFEFF/, ""));
      const isAllowed = checkRole(mapper, localScope, action, role);
      if (isAllowed) {
        next();
      } else {
        res.status(403).json({});
      }>>> import json
>>> data = {'people':[{'name': 'Scott', 'website': 'stackabuse.com', 'from': 'Nebraska'}]}
>>> json.dumps(data, indent=4)
{
    "people": [
        {
            "website": "stackabuse.com", 
            "from": "Nebraska", 
            "name": "Scott"
        }
    ]
}

Source

Also in JavaScript: