From af576efb51a4a1edd3c66d14a7f26f24c0b4192b Mon Sep 17 00:00:00 2001 From: Christian Romeyke Date: Tue, 22 Nov 2016 01:05:33 +0100 Subject: [PATCH] Customize object names --- src/js/JSONEditor.js | 2 +- src/js/Node.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/js/JSONEditor.js b/src/js/JSONEditor.js index 7420d4951..94186b2f0 100644 --- a/src/js/JSONEditor.js +++ b/src/js/JSONEditor.js @@ -81,7 +81,7 @@ function JSONEditor (container, options, json) { var VALID_OPTIONS = [ 'ace', 'theme', 'ajv', 'schema', - 'onChange', 'onEditable', 'onError', 'onModeChange', + 'onChange', 'onEditable', 'onError', 'onModeChange', 'onObjectName', 'escapeUnicode', 'history', 'search', 'mode', 'modes', 'name', 'indentation', 'sortObjectKeys' ]; diff --git a/src/js/Node.js b/src/js/Node.js index 8a6d0fa1c..9a224d562 100644 --- a/src/js/Node.js +++ b/src/js/Node.js @@ -1952,7 +1952,14 @@ Node.prototype.updateDom = function (options) { util.addClassName(this.dom.tr, 'jsoneditor-expandable'); } else if (this.type == 'object') { - domValue.innerHTML = '{' + count + '}'; + var objName; + if (typeof this.editor.options.onObjectName === 'function') { + objName = this.editor.options.onObjectName({ + path: this.getPath(), + children: this.childs + }); + } + domValue.innerHTML = '{' + (objName || count) + '}'; util.addClassName(this.dom.tr, 'jsoneditor-expandable'); } else {