# Possible to have {{context.hits}} return as an array?

**URL:** <https://discuss.elastic.co/t/possible-to-have-context-hits-return-as-an-array/277583>\
**Category:** Kibana\
**Created:** [July 1, 2021, 6:04pm UTC](https://discuss.elastic.co/t/possible-to-have-context-hits-return-as-an-array/277583 "2021-07-01T18:04:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandra\_Schlichting](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandra_schlichting/32/84122_2.png) [@Sandra\_Schlichting](https://discuss.elastic.co/u/Sandra_Schlichting)\
**Post date:** [July 1, 2021, 6:04pm UTC](https://discuss.elastic.co/t/possible-to-have-context-hits-return-as-an-array/277583/1 "2021-07-01T18:04:29Z")

</div>

Dear all =)

I would like to have `{{context.hits}}` as a JSON array, so I have tried different things.

If I put the following in a Kibana rule body

```auto
{"documents":"{{context.hits}}"}

```

then all the documents are stored as a string. if I do

```auto
{"documents":"[{{context.hits}}]"}

```

then it is closer to be an array, but it is still a string.

**Question**

Is it possible to get the documents in a real JSON array?

Hugs,  
Sandra =)

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [July 22, 2021, 1:35pm UTC](https://discuss.elastic.co/t/possible-to-have-context-hits-return-as-an-array/277583/2 "2021-07-22T13:35:33Z")

</div>

I'm not super familiar with rules, but have you tried to just write it without the `"`

```auto
{"documents": {{context.hits}}}

```

If using the `mustache` syntax , you should be able to write also non-valid JSON in the text, creating valid ones as output

---

<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:** [August 19, 2021, 1:36pm UTC](https://discuss.elastic.co/t/possible-to-have-context-hits-return-as-an-array/277583/3 "2021-08-19T13:36:21Z")

</div>

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