Socket
Socket
Sign inDemoInstall

@web-comp/json-viewer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web-comp/json-viewer

Console like JSON Viewer template.


Version published
Weekly downloads
142
increased by35.24%
Maintainers
1
Weekly downloads
 
Created
Source

JSON Viewer

Collapsible JSON viewer for templates in tree format. (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', ........};      //should be 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 -

Mostly same as angular, install and import modules (core and json viewer).

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

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

Keywords

FAQs

Package last updated on 06 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc