@n3bula/pretty-json
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

@n3bula/pretty-json

Install

npm install @n3bula/pretty-json
# or
yarn add @n3bula/pretty-json
# or
pnpm add @n3bula/pretty-json

Use

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@n3bula/pretty-json</title>
    <style>
      html,
      body {
        background: #222222;
      }
    </style>
  </head>

  <body>
    <div id="app"></div>
    <script src="../lib/umd/index.min.js"></script>
    <script>
      console.log(prettyJson);
      const map = new Map();
      map.set('a', 6);
      map.set({ a: 1, c: 2, d: true, b: [1, '3'] }, { b: false });
      map.set(map, map);
      prettyJson.toHTML(map).render('app');
      prettyJson
        .toHTML(
          [
            [1, 2, 3],
            [4, '5', 6],
            [7, 8, 9],
          ],
          {
            matrix: true,
            singleQuote: true,
          },
        )
        .render('app');
      const symbolKey = Symbol.for('key');
      const o = {
        [symbolKey]: Symbol.for('key'),
        xfd: [1, '2', null, false, [4, 5, [6]]],
        a: '1',
        test: function test(app) {
          console.log(app);
        },
        as: function (app) {
          console.log(app);
        },
        arrow: () => {},
        b: 2,
        c: true,
        d: {
          a: 1,
          b: new String('3'),
          c: Symbol('sdf'),
          d: {
            a: 234,
            b: 'asdf',
            c: false,
          },
        },
        g: NaN,
        asdfasfd: 'asdfadsfzcv',
      };
      o.xfd[5] = o;
      o.f = o;
      prettyJson
        .toHTML(o, {
          indent: 6,
        })
        .render('app');
    </script>
  </body>
</html>

pretty-json

Options

option value description
output string 'html' | 'text', default: 'html'
indent number default: 2
matrix boolean default: false
singleQuote boolean default: false,
trailingComma boolean default: true

Author

License

The MIT License(MIT)

Package Sidebar

Install

npm i @n3bula/pretty-json

Weekly Downloads

0

Version

0.0.5

License

MIT

Unpacked Size

114 kB

Total Files

8

Last publish

Collaborators

  • moriarty47