# How to pretty print json of a string field

**URL:** <https://discuss.elastic.co/t/how-to-pretty-print-json-of-a-string-field/98653>\
**Category:** Kibana\
**Created:** [August 29, 2017, 8:59am UTC](https://discuss.elastic.co/t/how-to-pretty-print-json-of-a-string-field/98653 "2017-08-29T08:59:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ea1987](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ea1987/32/51356_2.png) [@ea1987](https://discuss.elastic.co/u/ea1987)\
**Post date:** [August 29, 2017, 8:59am UTC](https://discuss.elastic.co/t/how-to-pretty-print-json-of-a-string-field/98653/1 "2017-08-29T08:59:24Z")

</div>

Hi all,  
is there a way to pretty print a json which is stored inside a string field? Right now Kibana visualize it in a 1 row, like this:

payload: { "name":"John", "age":30, "car":null }

This is what I would like to have:

payload:

{  
"name": "John",  
"age": 30,  
"car": null  
}

Can't find a way of doing that (I checked field formatter but it doesn't offer this choice).  
Thanks,

Andrea

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [August 30, 2017, 10:15am UTC](https://discuss.elastic.co/t/how-to-pretty-print-json-of-a-string-field/98653/2 "2017-08-30T10:15:18Z")

</div>

Hi @ea1987,

unfortunately there is no JSON field formatter yet. If you like you can open an enhancement request for that [on GitHub](https://github.com/elastic/kibana/issues/new). We are also open to receiving community PRs implementing such features. 😉

---

<div class="post-metadata">

**Author:** ![ea1987](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ea1987/32/51356_2.png) [@ea1987](https://discuss.elastic.co/u/ea1987)\
**Post date:** [August 30, 2017, 1:37pm UTC](https://discuss.elastic.co/t/how-to-pretty-print-json-of-a-string-field/98653/3 "2017-08-30T13:37:09Z")

</div>

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)

```

I suspect there is something wrong with this:

`require('ui/registry/field_formats').register(stringifyJson);`

But I don't know how to fix it.  
Can you please help me?  
Thanks,

Andrea

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [August 30, 2017, 3:21pm UTC](https://discuss.elastic.co/t/how-to-pretty-print-json-of-a-string-field/98653/4 "2017-08-30T15:21:30Z")

</div>

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

```
require('ui/registry/field_formats').RegistryFieldFormatsProvider.register(stringifyJson);
```

---

<div class="post-metadata">

**Author:** ![ea1987](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ea1987/32/51356_2.png) [@ea1987](https://discuss.elastic.co/u/ea1987)\
**Post date:** [August 30, 2017, 3:46pm UTC](https://discuss.elastic.co/t/how-to-pretty-print-json-of-a-string-field/98653/5 "2017-08-30T15:46:24Z")

</div>

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)

```

Do you know what's about?  
Thanks,

Andrea

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [August 30, 2017, 4:02pm UTC](https://discuss.elastic.co/t/how-to-pretty-print-json-of-a-string-field/98653/6 "2017-08-30T16:02:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 27, 2017, 4:02pm UTC](https://discuss.elastic.co/t/how-to-pretty-print-json-of-a-string-field/98653/7 "2017-09-27T16:02:45Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
