1.0.0-alpha.34 • Published 2 years ago
@liquid-labs/federated-json v1.0.0-alpha.34
federated-json
Library that builds a single JSON object from multiple JSON files.
Install
npm i @liquid-labs/federated-json
Usage
Example from src/example/example.js
:
import * as fjson from '../fjson/federated-json'
const data = {
"foo": {
"bar": {
"baz": { "field1": "val1", "field2": "val2" }
}
}
}
fjson.addMountPoint({ data, path: '.foo.bar', file: './data-foo-bar.json' })
// atm it's necessary to move the data pointer immediately under the previous mount
// It won't work now, but future versions will support:
// fjson.addMountPoint({ data, path: 'foo.bar.baz', file: './data-foo-bar-baz.json' })
fjson.addMountPoint({ data: data.foo.bar, path: '.baz', file: './data-foo-bar-baz.json' })
fjson.write({ data, file: `./data.json` })
// There are now three files; the root data and the two mount point files.
// by default, returns a single object which has the data and '_meta' elements combined
const dataWithMeta = fjson.read('./data.json')
console.log("With embedded meta-data:\n", JSON.stringify(dataWithMeta, null, 2))
const [ dataOnly, metaData ] = fjson.read('./data.json', { separateMeta : true })
console.log("\nSeparate meta-data:\n", JSON.stringify(metaData, null, 2))
console.log("\nSeparate data:\n", JSON.stringify(dataOnly, null, 2))
1.0.0-alpha.34
2 years ago
1.0.0-alpha.33
2 years ago
1.0.0-alpha.32
2 years ago
1.0.0-alpha.31
2 years ago
1.0.0-alpha.30
3 years ago
1.0.0-alpha.29
3 years ago
1.0.0-alpha.28
3 years ago
1.0.0-alpha.27
3 years ago
1.0.0-alpha.26
3 years ago
1.0.0-alpha.25
3 years ago
1.0.0-alpha.24
3 years ago
1.0.0-alpha.23
3 years ago
1.0.0-alpha.22
3 years ago
1.0.0-alpha.21
3 years ago
1.0.0-alpha.20
4 years ago
1.0.0-alpha.19
4 years ago
1.0.0-alpha.18
4 years ago
1.0.0-alpha.17
4 years ago
1.0.0-alpha.16
4 years ago
1.0.0-alpha.15
4 years ago
1.0.0-alpha.14
4 years ago
1.0.0-alpha.13
4 years ago
1.0.0-alpha.11
4 years ago
1.0.0-alpha.10
4 years ago
1.0.0-alpha.9
4 years ago
1.0.0-alpha.8
4 years ago
1.0.0-alpha.7
4 years ago
1.0.0-alpha.6
4 years ago
1.0.0-alpha.3
4 years ago
1.0.0-alpha.2
4 years ago