Convert event to JSON

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?

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