json-reference-parser

0.0.2 • Public • Published

Generic badge Generic badge Generic badge

JSON Reference Parser

This package parses the json and dereferences reference '($ref)' objects inside it

Installation

Run below command

npm install json-reference-parser

Problem

Sometimes JSON may contain $ref that referes to other object inside the JSON,

{
    "theme": {
      "$ref": "#/definitions/themes"
    }
    "definitions": {
        "themes": {
            "color": "blue",
            "material": false
        }
    }
}

Solution

Using this package JSON given in problem statement can be passed to dereference method which would dereference all the references inside it

{
    "theme": {
            "color": "blue",
            "material": false
    }
    "definitions": {
        "themes": {
            "color": "blue",
            "material": false
        }
    }
}

Usage

import * as DereferenceJSON from json-reference-parser
...
var dereferenceObject = new DereferenceJSON();
dereferenceObject.dereference(json)

Package Sidebar

Install

npm i json-reference-parser

Weekly Downloads

3

Version

0.0.2

License

MIT

Unpacked Size

3.1 kB

Total Files

3

Last publish

Collaborators

  • mani_96