2.0.3 • Published 3 years ago

foof-json-viewer v2.0.3

Weekly downloads
22
License
MIT
Repository
github
Last release
3 years ago

foof-json-viewer

JSON viewer for Angular

Live demo: https://stackblitz.com/edit/foof-json-viewer

Install

npm install foof-json-viewer

NPM Package: https://www.npmjs.com/package/foof-json-viewer

Usage

In your app.module.ts import FoofJsonViewerModule like

import { FoofJsonViewerModule } from 'foof-json-viewer';

@NgModule({
  ...,
  imports: [
    ...,
  FoofJsonViewerModule,
  ...
],
...
})
export class AppModule { }

In your component:

<foof-json-viewer [json]="someObject"></foof-json-viewer>

To collapse all nodes at first:

<foof-json-viewer [json]="someObject" [expanded]="false"></foof-json-viewer>

To make the segment clickable

HTML

<foof-json-viewer [json]="someObject"
                  [isSegmentClickable]="isClickable"
                  (segmentClicked)="segmentClickHandler($event)"></foof-json-viewer>

TS

const someObject = {users:[{id:123, name:"user1"},{id:234, name:"user2"}]};

function isClickable(segment:FoofJsonSegment):boolean{
  return segment.path === "users.0.id";
}
function segmentClickHandler(segmentClick:FoofJsonViewerComponentClickEvent){
  if (segmentClick.segment.path === "users.0.id"){
    console.log(`the userId is ${segmentClick.segment.value}`);
  }
}
2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago