# How Can I Control JSON Parsing Depth?

**URL:** https://discuss.elastic.co/t/how-can-i-control-json-parsing-depth/269969
**Category:** Beats
**Tags:** filebeat
**Created:** [April 13, 2021, 6:37am UTC](https://discuss.elastic.co/t/how-can-i-control-json-parsing-depth/269969 "2021-04-13T06:37:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![danielc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielc/32/78486_2.png) [@danielc](https://discuss.elastic.co/u/danielc)
#### Post date: [April 13, 2021, 6:37am UTC](https://discuss.elastic.co/t/how-can-i-control-json-parsing-depth/269969/1 "2021-04-13T06:37:42Z")

</div>

In [Decode JSON fields | Filebeat Reference [7.12] | Elastic](https://www.elastic.co/guide/en/beats/filebeat/current/decode-json-fields.html)

```
max_depth
(Optional) The maximum parsing depth. A value of 1 will decode the JSON objects in fields 
indicated in fields, a value of 2 will also decode the objects embedded in the fields of these parsed 
documents. The default is 1.

```

So I have this config:

```
processors:
    - decode_json_fields:
          fields: ["message"]
          target: "json"
          process_array: false
          max_depth: 1
          add_error_key: true

```

However, all of json fields are parsed. e.g. `json.data.response.payload.message`. Now total number of fields has exceeded 1000.

How can I control the depth to reduce the number of fields?

---

<div class="post-metadata">

### Author: ![mtojek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mtojek/32/63863_2.png) [@mtojek](https://discuss.elastic.co/u/mtojek)
#### Post date: [April 13, 2021, 8:16am UTC](https://discuss.elastic.co/t/how-can-i-control-json-parsing-depth/269969/2 "2021-04-13T08:16:50Z")

</div>

Hm.. I'm not sure if there is such mechanism. Did you try to use the script processor?

---

<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: [May 11, 2021, 10:17am UTC](https://discuss.elastic.co/t/how-can-i-control-json-parsing-depth/269969/3 "2021-05-11T10:17:41Z")

</div>

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