# Logstash JSON Filter Error

**URL:** <https://discuss.elastic.co/t/logstash-json-filter-error/340496>\
**Category:** Logstash\
**Created:** [August 9, 2023, 9:47pm UTC](https://discuss.elastic.co/t/logstash-json-filter-error/340496 "2023-08-09T21:47:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)\
**Post date:** [August 9, 2023, 9:47pm UTC](https://discuss.elastic.co/t/logstash-json-filter-error/340496/1 "2023-08-09T21:47:03Z")

</div>

I've pulled data from a SQL database that gets put into a field like below.

```auto
    "assignment": [
      {
        "assignedto": "1234",
        "assignedtoname": "John Doe",
        "assignedgroupid": 1
      }
    ]

```

I'm using the following JSON config in my pipeline.

```auto
  if [assignment] {
    json {
      source => "[assignment][0]"
      target => "assigned"
    }
  }

```

This results in the following error. What am I doing wrong?

```auto
[WARN][logstash.filters.json] Error parsing json {:source=>"[assignment][0]", :raw=>{"assignedto"=>1234, "assignedtoname"=>"John Doe", "assignedgroupid"=>1}, :exception=>#<Java::JavaLang::ClassCastException: >}

```

---

<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:** [August 10, 2023, 1:15am UTC](https://discuss.elastic.co/t/logstash-json-filter-error/340496/2 "2023-08-10T01:15:09Z")

</div>

> [@wwalker](#):
>
> `[WARN][logstash.filters.json] Error parsing json {:source=>"[assignment][0]", :raw=>{"assignedto"=>1234, "assignedtoname"=>"John Doe", "assignedgroupid"=>1},`

Note that the :raw value has `"assignedto"=>1234`, not `"assignedto": "1234"`. So [assignment][0] is a hash, not a string. I would guess you have a JSON column in the DB and the jdbc input parsed it for you.

---

<div class="post-metadata">

**Author:** ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)\
**Post date:** [August 10, 2023, 2:25pm UTC](https://discuss.elastic.co/t/logstash-json-filter-error/340496/3 "2023-08-10T14:25:22Z")

</div>

Does the raw value include the `{}`?

```auto
{
  "assignedto"=>1234,
  "assignedtoname"=>"John Doe",
  "assignedgroupid"=>1
}

```

or

```auto
"assignedto"=>1234,
"assignedtoname"=>"John Doe",
"assignedgroupid"=>1

```

---

<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:** [September 7, 2023, 2:26pm UTC](https://discuss.elastic.co/t/logstash-json-filter-error/340496/4 "2023-09-07T14:26:16Z")

</div>

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