Skip to content
File System Object Notation - construct json-like javascript objects from directory tree
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.gitignore
LICENSE
README.md
package.json

README.md

FSON

File System Object Notation - A function constructing json-like javascript objects from directory tree. Folders become JavaScript Objects. Files in a folder - properties of the object. As a result an fs tree

  • settings
    • foo
      • config.json
      • data.json
    • bar
      • config.json

will produce javascript objects:

{
 "foo": {
    "config": "config.json contents come here",
    "data": "and data.json contents"
  },
  "bar": {
    "config": 1234
  }
}

and dotted filenames are broken into multiple objects. For example reading settings:

  • settings
    • foo.bar
      • config.json
    • exam.ple.json

will result in

{
  "foo": {
    "bar":{
      "config":"config.json contents"
    }
  },
  "exam":{
    "ple": "exam.ple.json contents"
  }
}

Example usage:

var SETTINGS_PATH = '/etc/nodeApp';
require('fson')(SETTINGS_PATH, function (error, settings) {
  //use settings
});
You can’t perform that action at this time.