# Convert event to JSON

**URL:** <https://discuss.elastic.co/t/convert-event-to-json/157126>\
**Category:** Logstash\
**Created:** [November 16, 2018, 7:29pm UTC](https://discuss.elastic.co/t/convert-event-to-json/157126 "2018-11-16T19:29:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davems](https://avatars.discourse-cdn.com/v4/letter/d/87869e/32.png) [@davems](https://discuss.elastic.co/u/davems)\
**Post date:** [November 16, 2018, 7:29pm UTC](https://discuss.elastic.co/t/convert-event-to-json/157126/1 "2018-11-16T19:29:42Z")

</div>

I have an event from my input like this:  
{  
"Name" =\> "A",  
"Description" =\> "B"  
}

I need to convert it to JSON for my output, but the event should be a sub node in the JSON - I want it to end up like so:

{  
"event": {  
"Name": "A",  
"Description": "B"  
}  
}

To make it slightly more complicated, the fields in the event may be different. (There may not always be a description field, and sometimes there may be a different field in there)

Is there a simple (or even not so simple) way to achieve this?

---

<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:** [December 14, 2018, 7:36pm UTC](https://discuss.elastic.co/t/convert-event-to-json/157126/2 "2018-12-14T19:36:19Z")

</div>

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