Generates a json table-schema by flattening some sample json
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.
example
src
test
.editorconfig
.eslintignore
.eslintrc
.gitignore
LICENSE
README.md
jest.config.js
package-lock.json
package.json
tsconfig.json
tslint.json

README.md

json2table-schema

CLI tool to generate a table-schema provided a path to some sample JSON.

The sample JSON should be an array of objects.

It will loop thru each object, flatten them down into a tabular format, and produce a schema compliant with this spec: https://frictionlessdata.io/docs/table-schema/

The "name" property will be alphanumeric with underscores -- this is compatible with Google BigQuery's tables, as well as likely every database under the sun.

In addition to the "name" field, it will also add a "jsonPath" property to each field.

This jsonPath is compliant with lodash/get for getting data from json blobs of the same shape.

It does NOT automatically fill in the "type" and "description" fields, but it does produce them as empty placeholders.


Installation

npm i -g json2table-schema

Usage

json2table-schema /path/to/example.json

Example

$ json2table-schema ./example/eg6.json | jq
{
  "fields": [
    {
      "name": "col1",
      "type": "string",
      "description": "",
      "jsonPath": "col1"
    },
...