https://github.com/alexandlazaris/replace-json
https://github.com/alexandlazaris/replace-json
json json-format replace-json
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/alexandlazaris/replace-json
- Owner: alexandlazaris
- Created: 2020-02-10T08:20:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-10T18:40:48.000Z (over 6 years ago)
- Last Synced: 2025-02-23T01:34:48.601Z (over 1 year ago)
- Topics: json, json-format, replace-json
- Language: JavaScript
- Size: 1.95 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# replace-json
1. `npm install`
2. Edit `replace.js` to modify the JSON data to be replaced
3. `npm run main` - runs `replace.js` to replace JSON data & `format.js` to format JSON data
## Result
A JSON string belonging to a JSON file is read in and parsed as an Object. This Object then replaces the contents of a JSON file with formatting.
### Before
```
{
"key": "value","test": "data",
"hello":
"world"
}
or
{
"key": "This is a new value",
"test": "data",
"hello": "world",
"parent": {
"child": 1,
"child2": 22}
}
```
### After
```
{
"key": "value",
"test": "data",
"hello": "world"
}
and
{
"key": "This is a new value",
"test": "data",
"hello": "world",
"parent": {
"child": 1,
"child2": 22
}
}
```
## TODO
* Check if JSON key exists in file before overwriting
* Swap sync functions with async
* Replace multiple JSON key values at different levels
* Error handling (currently assumes all inputs are available)