# Format json

**URL:** <https://discuss.elastic.co/t/format-json/135529>\
**Category:** Logstash\
**Created:** [June 12, 2018, 12:12pm UTC](https://discuss.elastic.co/t/format-json/135529 "2018-06-12T12:12:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![joce455](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@joce455](https://discuss.elastic.co/u/joce455)\
**Post date:** [June 12, 2018, 12:12pm UTC](https://discuss.elastic.co/t/format-json/135529/1 "2018-06-12T12:12:22Z")

</div>

Hi all, i have a log in json format:

[{"id":"917066d5-5244-42e1-9343-49ccefe5b8cb","name":"data1","dataamount":1024000,"notification":0}]

And I want to transform in this:  
id:917066d5-5244-42e1-9343-49ccefe5b8cb  
name: data1  
dataamount:102400  
notification: 0

The porpouse is see this in kibana.  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [June 12, 2018, 1:00pm UTC](https://discuss.elastic.co/t/format-json/135529/2 "2018-06-12T13:00:04Z")

</div>

I suspect you won't be able to use the json or json\_lines _codecs_ since it's an array, but you can use a json _filter_ to deserialize the JSON string. Then use a mutate filter to rename (move) the fields into the top level of the event.

---

<div class="post-metadata">

**Author:** ![joce455](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@joce455](https://discuss.elastic.co/u/joce455)\
**Post date:** [June 18, 2018, 11:20pm UTC](https://discuss.elastic.co/t/format-json/135529/3 "2018-06-18T23:20:00Z")

</div>

thanks magnus, but i want a way to transform this log by with out using the names of each json value, there is a way to do that?, the reason is that i have to many differents json formats in my logs, for example  
one:  
[{"id":"917066d5-5244-42e1-9343-49ccefe5b8cb","name":"data1","dataamount":1024000,"notification":0}]  
two:  
[{"id":"917066d5-5244-42e1-9343-49ccefe5b8cb","name":"data1","dataamount":1024000,"notification":0}"field3":120012,"field4":wwa]  
three:  
[{"id":"917066d5-5244-42e1-9343-49ccefe5b8cb","name":"data1","dataamount":1024000,"notification":0}"field3":120012,"field4":wwa,"field5":45454]

And many other variations, is posible to use a general filter that apply to all this logs? Or I have to use a differente filter to each one.  
thanks

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [June 19, 2018, 6:14am UTC](https://discuss.elastic.co/t/format-json/135529/4 "2018-06-19T06:14:25Z")

</div>

You can use a ruby filter to copy/move fields with dynamic names. Examples of how to do that have been posted here in the past.

---

<div class="post-metadata">

**Author:** ![joce455](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@joce455](https://discuss.elastic.co/u/joce455)\
**Post date:** [June 19, 2018, 2:17pm UTC](https://discuss.elastic.co/t/format-json/135529/5 "2018-06-19T14:17:51Z")

</div>

Magnus could you giveme an example please? or some criteria to search, I try to find examples, but with out luck.

---

<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:** [July 17, 2018, 2:18pm UTC](https://discuss.elastic.co/t/format-json/135529/6 "2018-07-17T14:18:02Z")

</div>

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