# In filebeat, what is the difference between json.keys\_under\_root and decode\_json\_fields

**URL:** <https://discuss.elastic.co/t/in-filebeat-what-is-the-difference-between-json-keys-under-root-and-decode-json-fields/202732>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [October 8, 2019, 9:17pm UTC](https://discuss.elastic.co/t/in-filebeat-what-is-the-difference-between-json-keys-under-root-and-decode-json-fields/202732 "2019-10-08T21:17:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_eapen](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@john\_eapen](https://discuss.elastic.co/u/john_eapen)\
**Post date:** [October 8, 2019, 9:17pm UTC](https://discuss.elastic.co/t/in-filebeat-what-is-the-difference-between-json-keys-under-root-and-decode-json-fields/202732/1 "2019-10-08T21:17:11Z")

</div>

I am confused about the difference between json.keys\_under\_root and decode\_json\_fields.

1. Are these overlapping options ? I need the fields to be under root.
2. I am getting these error and was wondering if decode\_json\_fields can help overcome it.  
// ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/5/c5ec4ca80567cf1e6d9133b3a4ed414b378ca790.png) //"type":"mapper\_parsing\_exception","reason":"object mapping for [service] tried to parse field [service] as object, but found a concrete value"

---

<div class="post-metadata">

**Author:** ![Michal\_Pristas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michal_pristas/32/46639_2.png) [@Michal\_Pristas](https://discuss.elastic.co/u/Michal_Pristas)\
**Post date:** [October 9, 2019, 10:49am UTC](https://discuss.elastic.co/t/in-filebeat-what-is-the-difference-between-json-keys-under-root-and-decode-json-fields/202732/2 "2019-10-09T10:49:06Z")

</div>

> [@john\_eapen](#):
>
> decode\_json\_fields

the difference is that `decode_json_field` takes a string field and makes an object out of it  
so when applied to `key2` you will get from:

```json
{
  "key1": 1,
  "key2": "{\"key3\": 3}"
}

```

to

```json
{
  "key1": 1,
  "key2": {
      "key3": 3
  }
}

```

you can see that string in `key2` was replaced by object

`json.keys_under_root` on the other hand moves them from `json` key  
to the root so you will go from

```json
{
    "type": "test_type",
    "json": {
        "type": "test",
        "text": "hello",
    }
}

```

to

```json
{
    "type": "test_type",
    "text": "hello",
}

```

you can see type was not overwritten despite being under `json` key. if you want keys to be overwritten by what you have under `json` you should use `json.overwrite_keys: true`

---

<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:** [November 6, 2019, 10:53am UTC](https://discuss.elastic.co/t/in-filebeat-what-is-the-difference-between-json-keys-under-root-and-decode-json-fields/202732/3 "2019-11-06T10:53:09Z")

</div>

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