pretty-print object attributes in dev-state panel. (#195)

This commit is contained in:
Andrey 2017-02-07 21:51:51 +02:00 committed by Paulus Schoutsen
parent 5a60694587
commit 05760f9c21

View File

@ -188,10 +188,15 @@ Polymer({
var i;
var keys;
var key;
var value;
for (i = 0, keys = Object.keys(entity.attributes); i < keys.length; i++) {
key = keys[i];
output += key + ': ' + entity.attributes[key] + '\n';
value = entity.attributes[key];
if (!Array.isArray(value) && (value instanceof Object)) {
value = JSON.stringify(value, null, ' ');
}
output += key + ': ' + value + '\n';
}
return output;