# How to filter json object field class, java.lang.ClassCastException: class org.jruby.RubyHash cannot be cast to class org.jruby.RubyIO

**URL:** <https://discuss.elastic.co/t/how-to-filter-json-object-field-class-java-lang-classcastexception-class-org-jruby-rubyhash-cannot-be-cast-to-class-org-jruby-rubyio/311779>\
**Category:** Logstash\
**Created:** [August 10, 2022, 1:20am UTC](https://discuss.elastic.co/t/how-to-filter-json-object-field-class-java-lang-classcastexception-class-org-jruby-rubyhash-cannot-be-cast-to-class-org-jruby-rubyio/311779 "2022-08-10T01:20:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HeChuanXUPT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hechuanxupt/32/109455_2.png) [@HeChuanXUPT](https://discuss.elastic.co/u/HeChuanXUPT)\
**Post date:** [August 10, 2022, 1:20am UTC](https://discuss.elastic.co/t/how-to-filter-json-object-field-class-java-lang-classcastexception-class-org-jruby-rubyhash-cannot-be-cast-to-class-org-jruby-rubyio/311779/1 "2022-08-10T01:20:45Z")

</div>

# input file content:

```auto
{"_source": {"timestamp": 1612256372000, "date": "2021-02-02 16:59:32", "ip": "127.175.208.130"}}

```

# logstash.conf:

```auto
input {
  file {
    path => ["/tmp/test_file"]
    start_position => "beginning"
    sincedb_path => "/dev/null"
    codec => "json"
  }
}

filter {
  json {
    source => "_source"
  }
}

output {
  stdout {
    codec => json
  }
}

```

# what I want

get items in "\_source", output a json string, like:

```auto
{"timestamp": 1612256372000, "date": "2021-02-02 16:59:32", "ip": "127.175.208.130"}

```

# Error messages

```auto
[2022-08-10T09:13:01,703][WARN][logstash.filters.json][main][0c12318dee7f757738758c58cf376100c2248bec3723d1da4215be2e98a76069] Error parsing json {:source=>"_source", :raw=>{"timestamp"=>1612256372000, "date"=>"2021-02-02 16:59:32", "ip"=>"127.175.208.130"}, :exception=>java.lang.ClassCastException: class org.jruby.RubyHash cannot be cast to class org.jruby.RubyIO (org.jruby.RubyHash and org.jruby.RubyIO are in unnamed module of loader 'app')}
{"@timestamp":"2022-08-10T01:13:01.550111Z","@version":"1","tags":["_jsonparsefailure"],"path":"/home/hechuan/logstash/logstash-8.3.3/qwe","host":"cdh-manager","_source":{"timestamp":1612256372000,"date":"2021-02-02 16:59:32","ip":"127.175.208.130"}}

```

---

<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, 2022, 1:21am UTC](https://discuss.elastic.co/t/how-to-filter-json-object-field-class-java-lang-classcastexception-class-org-jruby-rubyhash-cannot-be-cast-to-class-org-jruby-rubyio/311779/2 "2022-09-07T01:21:18Z")

</div>

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