@json-table/core

0.1.0 • Public • Published

@json-table/core

Set of tools for converting JSON data to table (HTML, XLSX, ASCII).

Install

npm install @json-table/core

Usage

import { makeBlockFactory } from "@json-table/core/json-to-table";
import { blockToASCII } from "@json-table/core/block-to-ascii";

const block = makeBlockFactory({
  cornerCellValue: "№",
  joinPrimitiveArrayValues: true,
});
const asciiTable = blockToASCII(block(data));

Input data:

{
  "key": "val",
  "primitiveArr": [1, "two", false],
  "object": {
    "key1": "value1",
    "key2": 789,
    "key3": {
      "nestedKey": "nestedVal"
    }
  },
  "nestedArray": [
    {
      "name": "John",
      "age": 30,
      "isStud": false
    },
    {
      "name": "Alice",
      "age": 25,
      "isStud": true
    }
  ]
}

Output:

+-----+---------------+---------------------------+--------------------------+
| key | primitiveArr  |          object           |         nestedArray      |
+-----+---------------+--------+------+-----------+---+-------+-----+--------+
|     |               |  key1  | key2 |   key3    | № | name  | age | isStud |
|     |               +--------+------+-----------+---+-------+-----+--------+
| val | 1, two, false |        |      | nestedKey | 1 | John  |  30 | false  |
|     |               | value1 |  789 +-----------+---+-------+-----+--------+
|     |               |        |      | nestedVal | 2 | Alice |  25 | true   |
+-----+---------------+--------+------+-----------+---+-------+-----+--------+

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.0
2latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.0
2
0.0.0
1

Package Sidebar

Install

npm i @json-table/core

Weekly Downloads

3

Version

0.1.0

License

MIT

Unpacked Size

134 kB

Total Files

103

Last publish

Collaborators

  • x0k