From d8273ab12fcbc5f2512158f957b4bca0b9f0894e Mon Sep 17 00:00:00 2001 From: STAFYNIAK Sacha Date: Mon, 17 Sep 2018 07:49:01 +0200 Subject: [PATCH] add an option to enable key sorting before display --- types/json-object.vue | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/json-object.vue b/types/json-object.vue index cf8ba10..05b3e97 100644 --- a/types/json-object.vue +++ b/types/json-object.vue @@ -3,7 +3,7 @@ { } @@ -22,14 +22,14 @@ export default { }, computed: { ordered () { - const ordered = {}; - if (this.sortKeys) { - Object.keys(this.jsonValue).sort().forEach(key => { - ordered[key] = this.jsonValue[key]; - }); - } else { - ordered = this.jsonValue + if (!this.sortKeys) { + return this.jsonValue; } + + const ordered = {}; + Object.keys(this.jsonValue).sort().forEach(key => { + ordered[key] = this.jsonValue[key]; + }); return ordered; } },