Skip to content

BENcorry/json-extend-reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

USAGE

Install

npm i json-extend-reader

Code

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 Type: string | string[]

extend allow to use type of string or string array

{
  "extend": ["./b.json"],
  "id": "33",
  "value": "corry"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published