| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Make Your JSON Great Again
Betterer-json allows users to programmatically edit (and hopefully make better-er) JSON files using JavaScript and JSONPath. It applies JSONPath to select multiple values and calls JavaScript functions to generate fixes.
Betterer-json executes a user-provided JS script with one or more calls to replace()
replace function accepts JSONPath and callback.
faulty.json:
{
"type": "string",
"format": "datetime"
}fix.js
/// replace 'format: datetime' with 'format: date-time'
replace('$..format', value => {
if(value === 'datetime')
return 'date-time'
else return value;
});better.json:
{
"type": "string",
"format": "date-time"
}npx betterer-json fix.js faulty.json > better.jsonThird party JSON documents often don't conform to their declared JSON Schema, which causes problems with processing them down the line. Updating them is a repetitive task, more so If these documents are updated often.
Most other JSON tools focus more on reporting or extracting data. The second-best is JSON Patch, but it changes documents one value at a time.
This project is just a fancy wrapper over a great JSON P3.
| Back | FazBrowse Home | New Git URL |