Fork, Commit, Merge - Medium Issue (JSON)
JSON Parsing and Manipulation (In Your Preferred Language)
Note: You don't have ask permission to start solving the issue or get assigned, since these issues are supposed to be always open for new contributors. The actions-user bot will reset the file back to previous state for the next contributor after your commit is merged. So you can just simply start working with the issue right away!
Description
The task is to parse and manipulate a given JSON object in data.json. The goal is to filter out specific fields, manipulate other fields, and then generate a new JSON object.
How to get started
Open the tasks/json/medium directory from the root of your project.
Then start working with your solution by creating a file (for example in JavaScript processJSON.js) in your preferred language.
Requirements
- Read the provided JSON file
data.jsonwhich contains an array of objects. - Filter out all objects where the status is inactive.
- Update the price field by applying a 10% tax.
- Write the resulting array of objects to a new JSON file called
updated_data.json.
Expected output (updated_data.json)
[
{
"name": "Product 1",
"price": 110,
"status": "active"
},
{
"name": "Product 3",
"price": 330,
"status": "active"
}
]If the script works correctly, you should see the product with status as inactive, filtered out from the result.
How to run
First, make sure you are in the correct directory:
Running your script depends on the language you have chosen to work with:
Using JavaScript:
Using Python:
Using Ruby:
After your script successfully creates new updated_data.json file, you are ready to make a pull request!
Check out README.md for more instructions and how to make a pull request.
Feel free to ask any questions here if you have some problems!
