unfortunately there is no JSON field formatter yet. If you like you can open an enhancement request for that on GitHub. We are also open to receiving community PRs implementing such features.
Hi @weltenwort,
thank you for your answer. I'm trying to build my own JSON field formatter, but I'm facing some issues while developing it (it's my first plugin and I can't find any updated how-to doc). I have just written down the plugin skeleton, leaving text and html function almost empty, just to check that everything works. This is basically the public/.js file:
function stringifyJson (Private) {
var _ = require('lodash');
var FieldFormat = Private(require('ui/index_patterns/_field_format/field_format'));
_.class(jsonFormat).inherits(FieldFormat);
function jsonFormat(params) {
jsonFormat.Super.call(this, params);
}
jsonFormat.id = 'jsonFormat';
jsonFormat.title = 'Jsoncode';
jsonFormat.fieldType = [
'string',
];
jsonFormat.prototype._convert = {
text: function (value) {
return value;
},
html: function (value) {
return value;
}
};
return jsonFormat;
}
require('ui/registry/field_formats').register(stringifyJson);
Everything seems to be fine according to Kibana's log, but this is the message I receive when I open Kibana:
Error: Object doesn't support property or method 'register' (http://localhost:5601/bundles/kibana.bundle.js?v=15443:262)
at window.onerror (http://localhost:5601/bundles/commons.bundle.js?v=15443:76:8856)
The module ui/registry/field_formats does not export the registry as the default export, but under the name RegistryFieldFormatsProvider. That means that it should be something like
Hi @weltenwort
Thank you for your suggestion. I tried that suggested code, now Kibana starts correctly but it doesn't show ui pages properly. I checked via console and found these 2 errors
TypeError: Expected private module "[object Object]" to be a function
at identify (commons.bundle.js?v=15443:82)
at Private (commons.bundle.js?v=15443:82)
at Object.stringifyJson (kibana.bundle.js?v=15443:262)
at Object.invoke (commons.bundle.js?v=15443:36)
at instantiate (commons.bundle.js?v=15443:82)
at get (commons.bundle.js?v=15443:82)
at Private (commons.bundle.js?v=15443:82)
at Array.map (<anonymous>)
at Object.registry (commons.bundle.js?v=15443:84)
at Object.invoke (commons.bundle.js?v=15443:36)
commons.bundle.js?v=15443:38 Error: Circular reference to "IndexPatternsProvider" found while resolving private deps: IndexPatternsProvider -> IndexPatternProvider -> registry -> stringifyJson
at instantiate (commons.bundle.js?v=15443:82)
at get (commons.bundle.js?v=15443:82)
at Private (commons.bundle.js?v=15443:82)
at new <anonymous> (kibana.bundle.js?v=15443:27)
at invoke (commons.bundle.js?v=15443:36)
at Object.instantiate (commons.bundle.js?v=15443:36)
at Object.<anonymous> (commons.bundle.js?v=15443:35)
at Object.invoke (commons.bundle.js?v=15443:36)
at Object.$get (commons.bundle.js?v=15443:35)
at Object.invoke (commons.bundle.js?v=15443:36)
Hm, that path ui/index_patterns/_field_format/field_format indicates that you are not using the latest Kibana version. Which version do you try to develop for?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.