Skip to content
Open
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
12 changes: 5 additions & 7 deletions JSONGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ JSONGrid.prototype.processArray = function () {

keys.forEach(function (key, keyIdx) {
var td = DOMHelper.createElement('td', typeof obj, 'table-wrapper');
var value = (obj[key] === undefined || obj[key] === null)
? '' + obj[key]
: obj[key]
;
var value = obj[key];
td.appendChild(new JSONGrid(value).generateDOM());
tr.appendChild(td);
});
Expand Down Expand Up @@ -140,14 +137,15 @@ JSONGrid.prototype.processObject = function () {

JSONGrid.prototype.generateDOM = function () {
var dom;
var dataType = this.data === null ? 'null' : typeof this.data; // typeof null is also 'object'

if (Array.isArray(this.data)) {
dom = this.processArray();
} else if (typeof this.data === 'object') {
} else if (dataType === 'object') {
dom = this.processObject();
} else {
// -- Create a span element and early return since this is a "leaf"
var span = DOMHelper.createElement('span', typeof this.data);
var span = DOMHelper.createElement('span', dataType);
span.textContent = '' + this.data;
return span;
}
Expand Down Expand Up @@ -185,4 +183,4 @@ JSONGrid.prototype.render = function () {
this.container.classList.add(DOMHelper.JSON_GRID_CONTAINER_CLASSNAME);
};

window.JSONGrid = JSONGrid;
window.JSONGrid = JSONGrid;