1.0.15 • Published 5 years ago

json2fson v1.0.15

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

json2fson

contributions welcome Build Status

JavaScript Object Notation to FileSystem Object Notation (json to fson) and back

Converts a JSON to a FSON and back:

Current status: Early alpha!

Installation

npm install --save json2fson

Usage

var json2fson = require("json2fson")

var data = {
  //The object you want to convert
  name: "John Doe",
  age: 20,
  colors: ["red", "green", "blue"],
  friends: {
    goodOnes: [
      {
        NAME: "Foo",
        AGE: 20,
      },
      {
        NAME: "Bar",
        AGE: 30,
      },
    ],
    OTHERS: [
      {
        NAME: "FooBar",
        AGE: 25.5,
      },
    ],
  },
  homeAddress: "Main St. #180",
}

json2fson.convert({ data: data })

Will create the following structure and contents inside the DB folder (./fson/ by default):

  • ./
    • fson/
      • data/
        • name (file containing "John Doe")
        • age (containing 20)
        • colors/
          • 0 ("red")
          • 1 ("green")
          • 2 ("blue")
        • friends/
          • good_ones/
            • 0/
              • n_a_m_e ("Foo")_
              • a_g_e (20)_
            • 1/
              • n_a_m_e ("Bar")_
              • a_g_e (30)_
          • _o_t_h_e_r_s/
            • 0/
              • n_a_m_e ("FooBar")_
              • a_g_e (25.5)_
        • homeaddress ("Main St. #180")_

Running tests

Do npm install and npm test to create the FSON above.

FSON rules

The following rules are followed:

  • Plain objects and arrays (strictly {...} and ...) are folders
  • Keys are files and values are file contents (i.e the object { name: "John" } will create a file called "name" containing "John").
  • Uppercase letters have a leading low dash "_" since OS' paths are not always case sensitive.

License

MIT © @adelriosantiago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago