JSON Parsing Lab
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.
- Import the
data.jsonfile using the
readFileSync()method from the
fs(File System) module of Node.js
- Parse the Json Object from the file string that is outputted by the
- Update the
ageproperty of the JSON Object
- Export the JSON Object using the
export defaultkeywords. This ensures that any other js file can direcltly import the data using their own name, instead of using a named exports.