0.0.5 • Published 10 months ago

mini-json2html v0.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

!Caution 🚧 Under Development



Library Usage

# install
npm install mini-json2html
# or
pnpm add mini-json2html
cat tests/sample.json
{
  "lorem": "ipsum",
  "content": [
    [
      "div",
      { "align": "center", "class": "wrapper" },
      [
        ["img", { "src": "example.com" }],
        ["img", { "src": "google.com" }]
      ]
    ],
    [
      "footer",
      { "class": "foot" },
      [
        ["a", { "href": "foobar.com" }, ["p", { "class": "hoge" }, "foo"]],
        ["i", { "class": "icon", "x11" "xorg" }]
      ]
    ]
  ]
}
jq '.content' < tests/sample.json | json2html
import { readFile } from 'node:fs/promises'
import json2html from 'mini-json2html'

const { content } = JSON.parse(await readFile('./sample.json', { encoding: 'utf8' }))
const html = json2html(content)
<div align="center" class="wrapper">
        <img src="example.com" />
        <img src="google.com" />
</div>
<footer class="foot">
        <a href="foobar.com">
                <p class="hoge">foo</p>
        </a>
        <i class="icon" x11="xorg" />
</footer>

CLI Installation

# install globally
npm i -g mini-json2html
# or
pnpm add -g mini-json2html

CLI Synopsis

json2html [-]|FILE

Reads input from standard input or FILE The - is optional pointing to stdin

Writes the output to stdout


CLI Usage

Read input from stdin and write result to stdout

cat content.json | json2html

Select and pipe a node with jq and redirect results to file

# pipe json input and write result to a file
jq '.content' < tests/sample.json | json2html > output.html

Read input from argument and write result to stdout

json2html content.json
# npx not tested
# npx mini-json2html sample.json

License

MIT

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.2-2

10 months ago

0.0.2-1

10 months ago

0.0.2-0

10 months ago