/jsonrefs

Resolves "_ref" references in JS object to JSON files

Primary LanguageJavaScriptMIT LicenseMIT

jsonrefs

Resolves "_ref" references in JS object to JSON files

Usage

npm install --save jsonrefs

test.json:

{
    "one": 1,
    "two": 2, 
    "object": {
        "child": {
            "_ref": "other.json"
        }
    }
}

other.json:

{
    "filename": "other.json",
    "this": "is",
    "a": "test"
}

use jsonrefs:

var jsonref = require('jsonrefs');

jsonref.parse(require('../jsonrefs/test.json'));

result:

{ 
    "one": 1,
    "two": 2,
    "object": { 
        "child": { 
            "filename": "other.json",
            "this": "is",
            "a": "test",
            "_oldref": "other.json" 
        } 
    } 
}