0.0.5 • Published 2 months ago

@n3bula/pretty-json v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@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

optionvaluedescription
outputstring'html' | 'text', default: 'html'
indentnumberdefault: 2
matrixbooleandefault: false
singleQuotebooleandefault: false,
trailingCommabooleandefault: true

Author

License

The MIT License(MIT)

0.0.5

2 months ago

0.0.5-alpha.1

8 months ago

0.0.5-alpha.0

8 months ago