# JSON filter (attempt to either prevent recursion or drop unwanted objects / nested fields)

**URL:** https://discuss.elastic.co/t/json-filter-attempt-to-either-prevent-recursion-or-drop-unwanted-objects-nested-fields/52903
**Category:** Logstash
**Created:** [June 15, 2016, 5:53pm UTC](https://discuss.elastic.co/t/json-filter-attempt-to-either-prevent-recursion-or-drop-unwanted-objects-nested-fields/52903 "2016-06-15T17:53:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![robinpblanchard](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@robinpblanchard](https://discuss.elastic.co/u/robinpblanchard)
#### Post date: [June 15, 2016, 5:53pm UTC](https://discuss.elastic.co/t/json-filter-attempt-to-either-prevent-recursion-or-drop-unwanted-objects-nested-fields/52903/1 "2016-06-15T17:53:10Z")

</div>

I have java/logback feeding a template a la:

```
                                    <pattern>
                                            {
                                            "environment" : "somecrazyenvironment",
                                            "appname" : "somecrazyapplication",
                                            "logger" : "%logger",
                                            "level" : "%level",
                                            "thread" : "%thread",
                                            "method" : "%class",
                                            "message" : "%message"
                                            }
                                    </pattern>

```

which the JSON filter properly handles (and placed into a target json container field "app")

However, the "message" often contains yet more nested JSON. This causes consternation and often field-type conflicts ('tried to parse field [FIELD] as object, but found a concrete value').

Is it possible to prevent descending into nested JSON? (preferred)

Or

Is it possible to do some mutate/drop using some sort of logic based on for [app][NOTsome\_json\_subfield\_i\_care\_about] ? (seems ugly)

thanks!

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [June 15, 2016, 6:06pm UTC](https://discuss.elastic.co/t/json-filter-attempt-to-either-prevent-recursion-or-drop-unwanted-objects-nested-fields/52903/2 "2016-06-15T18:06:45Z")

</div>

I'm not following. I'm pretty sure the json filter doesn't recurse into string fields and parse anything that looks like JSON. Could you give a minimal example that exhibits the problem?

---

<div class="post-metadata">

### Author: ![robinpblanchard](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@robinpblanchard](https://discuss.elastic.co/u/robinpblanchard)
#### Post date: [June 15, 2016, 6:24pm UTC](https://discuss.elastic.co/t/json-filter-attempt-to-either-prevent-recursion-or-drop-unwanted-objects-nested-fields/52903/3 "2016-06-15T18:24:36Z")

</div>

Perhaps the problem lies elsewhere. I'll follow-up with my java developers. Despite their running application having a logback configured to send the above template, I am finding many more fields (aside those listed) being expanded....

---

<div class="post-metadata">

### Author: ![shaimr](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@shaimr](https://discuss.elastic.co/u/shaimr)
#### Post date: [September 8, 2016, 8:05am UTC](https://discuss.elastic.co/t/json-filter-attempt-to-either-prevent-recursion-or-drop-unwanted-objects-nested-fields/52903/4 "2016-09-08T08:05:31Z")

</div>

I'm facing the same problem. How can I prevent JSON filter to parse the nested objects?

I opened a stackoverflow question:  
[http://stackoverflow.com/questions/39371129/logstash-json-filter-for-only-one-level](http://stackoverflow.com/questions/39371129/logstash-json-filter-for-only-one-level)

---

<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, 2017, 4:39am UTC](https://discuss.elastic.co/t/json-filter-attempt-to-either-prevent-recursion-or-drop-unwanted-objects-nested-fields/52903/5 "2017-07-06T04:39:20Z")

</div>


