jsre: fix wrong separator comma placing due to non consistent field orders

This commit is contained in:
Péter Szilágyi 2015-06-09 13:27:45 +03:00
parent 11f65cf885
commit 3f4ce70d92
1 changed files with 7 additions and 7 deletions

View File

@ -26,19 +26,19 @@ function pp(object, indent) {
} else if(typeof(object) === "object") { } else if(typeof(object) === "object") {
str += "{\n"; str += "{\n";
indent += " "; indent += " ";
var last = getFields(object).pop()
getFields(object).forEach(function (k) { var fields = getFields(object);
str += indent + k + ": "; var last = fields[fields.length - 1];
fields.forEach(function (key) {
str += indent + key + ": ";
try { try {
str += pp(object[k], indent); str += pp(object[key], indent);
} catch (e) { } catch (e) {
str += pp(e, indent); str += pp(e, indent);
} }
if(key !== last) {
if(k !== last) {
str += ","; str += ",";
} }
str += "\n"; str += "\n";
}); });
str += indent.substr(2, indent.length) + "}"; str += indent.substr(2, indent.length) + "}";