JSON Parsing Lab
Revised Instructions
In this exercise lab, the primary focus is to enhance your skills associated with various JSON operations. You will delve into manipulating JSON strings, accessing and modifying their properties, and concluding with exporting the revised JSON object.
To accomplish these tasks, the JSON.parse()
function has to be employed to structure the received JSON string and store it in a suitable variable. This will facilitate easy access to JSON object properties. You are then expected to update these property values to new ones as required and complete the operation by exporting the newly modified JSON object using the 'export' keyword.
For a better understanding of these operations, you will work interactively with the data.json
file provided. This real-time experience will ensure you grasp the core concepts effectively while enjoying the hands-on challenges.
Instructions
- Import the
data.json
file using thereadFileSync()
method from thefs
(File System) module of Node.js - Parse the Json Object from the file string that is outputted by the
readFileSync()
method - Update the
age
property of the JSON Object - Export the JSON Object using the
export default
keywords. This ensures that any other js file can direcltly import the data using their own name, instead of using a named exports.