# Conditional is not working to find nested JSON field

**URL:** <https://discuss.elastic.co/t/conditional-is-not-working-to-find-nested-json-field/190430>\
**Category:** Logstash\
**Created:** [July 15, 2019, 6:04am UTC](https://discuss.elastic.co/t/conditional-is-not-working-to-find-nested-json-field/190430 "2019-07-15T06:04:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![76a99de1e92a429af5f9](https://avatars.discourse-cdn.com/v4/letter/7/b782af/32.png) [@76a99de1e92a429af5f9](https://discuss.elastic.co/u/76a99de1e92a429af5f9)\
**Post date:** [July 15, 2019, 6:04am UTC](https://discuss.elastic.co/t/conditional-is-not-working-to-find-nested-json-field/190430/1 "2019-07-15T06:04:57Z")

</div>

Hi, I used logstash filter to avoid mapper-parsing-exception in this case.

- JSON Data  
{"request\_body":{  
"enveloped\_message":{"X":"x", "Y":"y"}  
}  
OR  
{"request\_body":"ABC"}

- logstash filter config  
if "enveloped\_message" in [request\_body] {  
mutate {  
rename =\> { "request\_body" =\> "request\_body\_json" }  
}  
}

- result  
request\_body : ABC  
request\_body\_json.enveloped\_message.X : x  
request\_body\_json.enveloped\_message.Y : y

- Problem  
conditional can't found enveloped\_message!  
so rename is not working, mapping conflict error in request\_body

It was work in 6.1.2 logstash, but now is'nt work after upgrade to logstash 7.2.0

Why is not working?? I can't found in upgrade note what difference in conditional  
How to find if field have injesting field?

Plz, I need your help. T\_T

Thank you.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 15, 2019, 2:59pm UTC](https://discuss.elastic.co/t/conditional-is-not-working-to-find-nested-json-field/190430/2 "2019-07-15T14:59:24Z")

</div>

> [@76a99de1e92a429af5f9](#):
>
> if "enveloped\_message" in [request\_body] {

You can use "in" for array membership, or for substring matching against a string, but I don't think you can use it to test whether a field exists in an object. Try

```
if [request_body][enveloped_message] {

```

---

<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 12, 2019, 2:59pm UTC](https://discuss.elastic.co/t/conditional-is-not-working-to-find-nested-json-field/190430/3 "2019-08-12T14:59:26Z")

</div>

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