find-json

0.0.1 • Public • Published

Find and Query agains a JSON file

This module is used to traverse up a directory structure looking for a json file. It can find and read in the file, then provide a simple query method agains the data. By default it will look for a package.json.

Examples:

var File = require('find-json');
 
var f = new File();
f.read(function() {
    f.get('version'); // '0.0.1'
    f.get('repository:url'); // 'https://github.com/wesleytodd/find-json.git'
}):
// Directory Structure:
// - config.json
// - foo/
// | - other.js
// 
// Run from in foo:
// $ node ./other.js
// 
// File: config.json
{
    "db": {
        "host": "localhost"
    }
}
 
// File: other.js
var File = require('find-json');
 
var f = new File({
    filename: 'config.json',
    delim: '.'
});
f.readSync();
 
f.get('db'); // {host: 'localhost'}
f.get('db.host'); // 'localhost'

Readme

Keywords

Package Sidebar

Install

npm i find-json

Weekly Downloads

2

Version

0.0.1

License

ISC

Last publish

Collaborators

  • wesleytodd