From 3f4ce70d9263ff635385d694b9ac3f3c5ad8de12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 9 Jun 2015 13:27:45 +0300 Subject: [PATCH] jsre: fix wrong separator comma placing due to non consistent field orders --- jsre/pp_js.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/jsre/pp_js.go b/jsre/pp_js.go index 5c09b2586..4e0a04f83 100644 --- a/jsre/pp_js.go +++ b/jsre/pp_js.go @@ -26,19 +26,19 @@ function pp(object, indent) { } else if(typeof(object) === "object") { str += "{\n"; indent += " "; - var last = getFields(object).pop() - getFields(object).forEach(function (k) { - str += indent + k + ": "; + + var fields = getFields(object); + var last = fields[fields.length - 1]; + fields.forEach(function (key) { + str += indent + key + ": "; try { - str += pp(object[k], indent); + str += pp(object[key], indent); } catch (e) { str += pp(e, indent); } - - if(k !== last) { + if(key !== last) { str += ","; } - str += "\n"; }); str += indent.substr(2, indent.length) + "}";