From 0a7ec9241f261dca62efebc16a561f8212c22f70 Mon Sep 17 00:00:00 2001 From: Vikram Biwal Date: Fri, 7 Jan 2022 13:22:58 +0530 Subject: [PATCH 1/2] Add support for Double Quotes on keys --- README.md | 1 + lib/json-box.vue | 4 +++- lib/json-viewer.vue | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a97e290..d22e413 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,7 @@ import 'vue-json-viewer/style.css' | `timeformat` | custom time format function | time => time.toLocaleString() | | `preview-mode` | no expand mode | `false` | | `show-array-index` | array show index | `true` | +| `show-double-quotes` | show double quotes | `true` | ## Listeners diff --git a/lib/json-box.vue b/lib/json-box.vue index 8afb4bf..78f60fc 100644 --- a/lib/json-box.vue +++ b/lib/json-box.vue @@ -28,6 +28,7 @@ export default { previewMode: Boolean, forceExpand: Boolean, showArrayIndex: Boolean, + showDoubleQuotes: Boolean, }, data() { return { @@ -119,7 +120,7 @@ export default { 'jv-key': true }, domProps: { - innerText: `${this.keyName}:` + innerText: this.showDoubleQuotes ? `"${this.keyName}":` : `${this.keyName}:` } })) } @@ -137,6 +138,7 @@ export default { previewMode: this.previewMode, forceExpand: this.forceExpandMe, showArrayIndex: this.showArrayIndex, + showDoubleQuotes: this.showDoubleQuotes, }, on: { 'update:expand': value => { diff --git a/lib/json-viewer.vue b/lib/json-viewer.vue index 5365041..1d8c637 100644 --- a/lib/json-viewer.vue +++ b/lib/json-viewer.vue @@ -30,6 +30,7 @@ :sort="sort" :preview-mode="previewMode" :show-array-index="showArrayIndex" + :show-double-quotes="showDoubleQuotes" />
Date: Fri, 7 Jan 2022 16:23:33 +0530 Subject: [PATCH 2/2] Updated types --- lib/json-box.vue | 2 +- lib/types/json-array.vue | 2 ++ lib/types/json-object.vue | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/json-box.vue b/lib/json-box.vue index 78f60fc..2b0cfe0 100644 --- a/lib/json-box.vue +++ b/lib/json-box.vue @@ -120,7 +120,7 @@ export default { 'jv-key': true }, domProps: { - innerText: this.showDoubleQuotes ? `"${this.keyName}":` : `${this.keyName}:` + innerText: this.showDoubleQuotes ? `"${this.keyName}":` : `${this.keyName}:` } })) } diff --git a/lib/types/json-array.vue b/lib/types/json-array.vue index 4b789b0..b3d7431 100644 --- a/lib/types/json-array.vue +++ b/lib/types/json-array.vue @@ -21,6 +21,7 @@ export default { forceExpand: Boolean, previewMode: Boolean, showArrayIndex: Boolean, + showDoubleQuotes: Boolean, }, data() { return { @@ -108,6 +109,7 @@ export default { previewMode: this.previewMode, forceExpand: this.forceExpand, showArrayIndex: this.showArrayIndex, + showDoubleQuotes: this.showDoubleQuotes, } })) }) diff --git a/lib/types/json-object.vue b/lib/types/json-object.vue index 77644e7..688baed 100644 --- a/lib/types/json-object.vue +++ b/lib/types/json-object.vue @@ -21,6 +21,7 @@ export default { sort: Boolean, previewMode: Boolean, showArrayIndex: Boolean, + showDoubleQuotes: Boolean, }, data() { return { @@ -119,6 +120,7 @@ export default { previewMode: this.previewMode, forceExpand: this.forceExpand, showArrayIndex: this.showArrayIndex, + showDoubleQuotes: this.showDoubleQuotes, } })) }