Skip to content

Commit

Permalink
fix(json-formatter): represent array of arrays properly (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
emoralesb05 authored Oct 2, 2017
1 parent 8a9b4db commit 42c8398
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export class JsonFormatterDemoComponent {
'numberProperty': 10000,
'booleanProperty': true,
'numberArray': [1, 2, 3, 4, 5, 6],
'arrayOfArrays': [
[1, [2, 3]],
[3, 4],
],
'objectArray': [{
'prop': undefined,
}, {
Expand Down
5 changes: 5 additions & 0 deletions src/platform/core/json-formatter/json-formatter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ export class TdJsonFormatterComponent {
return value.toString()
.replace(/[\r\n]/g, '')
.replace(/\{.*\}/, '') + '{…}';
} else if (Array.isArray(value)) {
return this.getObjectName() + ' [' + value.length + ']';
}
return value;
}
Expand All @@ -150,6 +152,9 @@ export class TdJsonFormatterComponent {
if (!object) {
return 'null';
}
if (Array.isArray(object)) {
return 'object';
}
let date: Date = new Date(object);
if (Object.prototype.toString.call(date) === '[object Date]') {
if (!Number.isNaN(date.getTime())) {
Expand Down

0 comments on commit 42c8398

Please sign in to comment.