@web-comp/json-viewer

Console like JSON Viewer template.
4,410 3
Install
npm install @web-comp/json-viewer
Latest Version:1.0.2
License:ISC
Last Updated:Jul 12, 2020
Links: GitHub  ·  npm
Maintainer: sudobird

JSON Viewer

Collapsible JSON viewer in tree format with console like UI.

Installation:

npm install @web-comp/core
npm install @web-comp/json-viewer

json viewer depends on @web-comp/core to work.

Usage:

import '@web-comp/core';
import '@web-comp/json-viewer';

template:

<div> // container div
    <wc-json-viewer id="myjson"></wc-json-viewer>
</div>

JS -

const element = document.getElementById("myjson");
const jsonData = {name: 'sudobird', ........};      // json array or object
element.setConfig({data: jsonData});

Example:

const jsonData = {
    name: "sudobird",
    age: 99,
    cities: ['abc', 'def', 'ghi'],
    gender: 'M',
    car: null,
    pan: 'BBGHGJ8485',
    isActive: false,
    jobs: [
        {title: 'Software Engineer', city: 'abc'},
        {title: 'Consultant', city: 'def'},
    ]
}

Usage with Angular:

  • npm install @web-comp/core @web-comp/json-viewer
  • set schemas: [CUSTOM_ELEMENTS_SCHEMA] in the module.
  • import core module and json-viewer module.
import '@web-comp/core';
import '@web-comp/json-viewer';
 <wc-json-viewer #jsonview></wc-json-viewer>
@ViewChild('jsonview') jsonview;
....
const jsonData = {....} // your json
this.jsonview.nativeElement.setConfig({data: jsonData});

Usage with React:

Install and import modules (core and json viewer)

import '@web-comp/core';
import '@web-comp/json-viewer';


<wc-json-viewer ref="jsonRef"></wc-json-viewer>

// in JS
componentDidMount() {
    this.jsonRef.current.setConfig({data: <jsonObj>});
}

Related Packages

@web-comp/date-picker

Date range picker web component for (angular, react, etc.)

2,690 3
hcx

HTML Compiler - Routeless, targetless, remote, runnable routes and more ...

468
eslint-plugin-smile

Smile ESLint rules for js, ts, react, vue, angular, next...

15,434 0

Version History

Version Released License
1.0.2 ISC
1.0.1 ISC
1.0.0 ISC