# How to convert the output into json in watcher body

**URL:** <https://discuss.elastic.co/t/how-to-convert-the-output-into-json-in-watcher-body/275293>\
**Category:** Elasticsearch\
**Created:** [June 8, 2021, 11:44am UTC](https://discuss.elastic.co/t/how-to-convert-the-output-into-json-in-watcher-body/275293 "2021-06-08T11:44:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mojahid\_Ahmad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mojahid_ahmad/32/78061_2.png) [@Mojahid\_Ahmad](https://discuss.elastic.co/u/Mojahid_Ahmad)\
**Post date:** [June 8, 2021, 11:44am UTC](https://discuss.elastic.co/t/how-to-convert-the-output-into-json-in-watcher-body/275293/1 "2021-06-08T11:44:23Z")

</div>

Hi, I want to convert the output into JSON format in the watcher body. I tried {{#toJson}}. But I couldn't get success. Please guide me through how to resolve this issue?

`"body": """{{#toJson}}{{#ctx.payload.hits.hits}} Source:5G Enterprise Status: Active Client_name: DOW Chemicals Metric Name: NDAC Radio FM Data KPI last_updated_time : {{_source.fm_data.last_updated_time}} Alarm_description : {{_source.fm_data.alarm_text}} Severity : {{_source.fm_data.severity}} Radio/Cell : {{_source.fm_data_source.dn}} Nhg_alias : {{_source.fm_data_source.nhg_alias}} Specific_problem : {{_source.fm_data.specific_problem}} Alarm_identifier : {{_source.fm_data.alarm_identifier}} Additional_text : {{_source.fm_data.additional_text}} {{/toJson}}{{/ctx.payload.hits.hits}}"""` Thanks

---

<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 6, 2021, 11:45am UTC](https://discuss.elastic.co/t/how-to-convert-the-output-into-json-in-watcher-body/275293/2 "2021-07-06T11:45:16Z")

</div>

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