1.1.1 • Published 7 years ago

modular-json v1.1.1

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

modular-json

Import JSON within JSON

How to use

npm install -g modular-json

modular-json depends on special keys called import[key] and import[key,flatten]

Key is necessary in case of flatten because files are parsed as JS objects. Hence not including the key means only the last import[flatten] key will remain. Here key is just used to distinguish between multiple flatten imports

Example 1 (without flatten)

// root.json
{
  "user": "fhalde",
  "import[contact]": "contact.json",
  "import[address]": "address.json"
}

// contact.json
{
  "phone": 1234567
}

// address.json
{
  "pincode": 415622,
  "state": "Foo"
}

> modular-json root.json

{
  "user": "fhalde",
  "contact": {
    "phone": 1234567
  },
  "address": {
    "pincode": 415622,
    "state": "Foo"
  }
}

Example 2 (with flatten)

// root.json
{
  "user": "fhalde",
  "import[contact, flatten]": "contact.json",
  "import[address, flatten]": "address.json"
}

// contact.json
{
  "phone": 1234567
}

// address.json
{
  "pincode": 415622,
  "state": "Foo"
}

> modular-json root.json

{
  "user": "fhalde",
  "phone": 1234567,
  "pincode": 415622,
  "state": "Foo"
}

Also

var modularJson = require('modular-json');
modularJson.parse('root.json');
1.1.1

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago