Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions projects/demo/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ <h3>Simple Types</h3>
<div class="json-container">
<ngx-json-treeview [json]="13" />
<ngx-json-treeview [json]="'hello, world!'" />
<ngx-json-treeview [json]="'hello, world!\nanother line!'" />
<ngx-json-treeview [json]="true" />
<ngx-json-treeview [json]="null" />
<ngx-json-treeview [json]="{}" />
Expand Down
8 changes: 7 additions & 1 deletion projects/demo/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class AppComponent {

baseObj = {
string: 'Hello World',
stringPre: 'Hello\nWorld\n\tAnother line',
number: 1234567890,
boolean: true,
url: 'http://www.google.com',
Expand Down Expand Up @@ -51,6 +52,11 @@ export class AppComponent {
}

stringify(obj: any) {
return typeof obj === 'function' ? '' + obj : JSON.stringify(obj, null, 2);
if (typeof obj === 'function') {
return '' + obj;
} else if (typeof obj === 'string') {
return obj;
}
return JSON.stringify(obj, null, 2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class NgxJsonTreeviewComponent {
break;
case 'string':
segment.type = 'string';
segment.description = '"' + segment.value + '"';
segment.description = JSON.stringify(segment.value);
break;
case 'undefined':
segment.type = 'undefined';
Expand Down