pointify v1.0.3
A browserify transform that resolves json pointers.A browserify transform that allows you to bundle json files inside other json files. Very loosely based on RFC 6901
Install
$ npm install --save pointify
Usage
var pointify = require('pointify');
var browserify = require('browserify');
var someJSONFile = require('./someJSONFile');
var b = browserify();
b.add(someJSONFile);
b.transform(pointify);
b.bundle(function(err, src){
console.dir(src);
//Prints {"owner":"{"name":"Gus"}};
});
//In some json file
{"owner": {"$ref":"owner.json"}
//or alternatively embed the $ref in a string (not part of the rfc)
{"owner":"$ref owner.json"}
//owner.json
{"name":"Gus"}
##Notes
Check out RFC6901 before you use this transform. There is a nice example of its benefits here in relation to json schema.
This transform only deals with references expected to be in other files at the moment.
Full support for in document schema is planned.
After using this on a project I no longer really see a need to support json pointer's syntax, doing so in a browserify transform seems like a lot of worth with little benifit. Maybe someday as an experiment, for now this transform is useful if you use what to have browserify combine some json files on your behalf.
All it does is require the json file and place it into the document. The requires are relative
to the document calling require. No longer uses requires, it will load the contents of the file
and parse them into JSON.
License
MIT © Lasana Murray