Skip to content

A Javascript library to resolve circular references in JSON exports by FastJson library

Notifications You must be signed in to change notification settings

moonmanbu/fastjson_ref_resolver

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastjson_ref_resolver

A Javascript library to resolve circular references in JSON exports by FastJson library

Install

npm install fastjson_ref_resolver

Usage

var Resolver = require('fastjson_ref_resolver').Resolver;
var data = [
    {
    carConfig: {
        colorOption: {
            description: "red color",
            name: "Red"
        },
    },
    id: "5719b01ed966d76a183a79e4",
    state: "OPEN"
    },
    {
    carConfig: {
        colorOption: {
            "$ref": "$[0].carConfig.colorOption"
        }
    },
    id: "5719b01ed966d76a183a79e5",
    state: "CLOSE"
    }
];

var resolved = new Resolver(data).resolve();
console.log(resolved);

The above code will print out

[
    {
    carConfig: {
        colorOption: {
            description: "red color",
            name: "Red"
        },
    },
    id: "5719b01ed966d76a183a79e4",
    state: "OPEN"
    },
    {
    carConfig: {
        colorOption: {
            description: "red color",
            name: "Red"
        }
    },
    id: "5719b01ed966d76a183a79e5",
    state: "CLOSE"
    }
];

About

A Javascript library to resolve circular references in JSON exports by FastJson library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%