GithubHelp home page GithubHelp logo

luke-clifton / json-directory Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 1.0 20 KB

Parse JSON values out of directory structures

License: BSD 3-Clause "New" or "Revised" License

Haskell 99.50% Shell 0.50%

json-directory's Introduction

JSON Directory

Provides utilities for reading JSON structures out of directories. Directory entries become keys in a map, and the values are sourced from the contets of each entry.

By default

  • Directories are recured into
  • Files ending with .json are read as JSON values
  • Everything else is interpreted as a string

However, these can be modified with rules, that allow for interpreting any sort of file as JSON.

The example directory in this repository would result in the following JSON value.

{
  "empty": {},
  "a": "This is files will have its contents written into a JSON string.\n",
  "d": {
    "example": "Sometimes it's convenient to embed some raw JSON"
  },
  "b": 42,
  "c": {
    "nested": "You can nest directories to create a tree structure.\n"
  }
}

jsondir

This package also includes an executable for turning directories into JSON blobs.

jsondir [--help] [--rule <SUFFIX> <FILTER> ...]
        [--[no-]default{s,-json,-text}] <ROOT> ...

  Turn a directory structure into a JSON value

 --rule <SUFFIX> <FILTER>     Filter the contents of files with the given
                              SUFFIX with FILTER. The default rules use .json
                              files as is, and treat everything else as strings.
                              Can be specified multiple times. Rule are tried in
                              the order specified.
 --[no-]defaults              Enable or disable the default rules. Default on.
 --[no-]default-json          Enable or disable the .json file rule
 --[no-]default-text          Enable or disable the raw file to JSON string rule.
 <ROOT>                       Directory root to turn into a JSON value

 EXAMPLE
  jsondir --rule '.yml' yaml2json ./my-dir

json-directory's People

Contributors

luke-clifton avatar robbiemcmichael avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

robbiemcmichael

json-directory's Issues

Support for YAML

It would be nice to be able to use YAML as an alternative to JSON. Are you open to adding a dependency on the yaml package and using it to decode files with extensions .yaml and .yml?

Alternatively, it might be possible to refactor this library to allow users to supply their own mapping from file extension to a function that can decode files of that type.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.