npm i json-extend-reader
import { jsonExtendReader } from "json-extend-reader";
// common
const { jsonExtendReader } = requie('json-extend-reader')
const res = jsonExtendReader(path.join(__dirname, "a.json"));
// a.json
{
"extend": "./b.json",
"id": "33",
"value": "corry"
}
// b.json
{
"id": "34",
"value": "corry2",
"size": 100,
"file": {
"extend": "./a.json"
}
}
// res will return
{
"id": "33",
"value": "corry",
"size": 100,
"file": {
"extend": "./a.json"
}
}
extend key must be in top-level, otherwise, it is invalid to load anther json file
extend allow to use type of string or string array
{
"extend": ["./b.json"],
"id": "33",
"value": "corry"
}