# Error parsing json using jdbc input

**URL:** <https://discuss.elastic.co/t/error-parsing-json-using-jdbc-input/48954>\
**Category:** Logstash\
**Created:** [May 2, 2016, 1:43pm UTC](https://discuss.elastic.co/t/error-parsing-json-using-jdbc-input/48954 "2016-05-02T13:43:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JvonRudno](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@JvonRudno](https://discuss.elastic.co/u/JvonRudno)\
**Post date:** [May 2, 2016, 1:43pm UTC](https://discuss.elastic.co/t/error-parsing-json-using-jdbc-input/48954/1 "2016-05-02T13:43:19Z")

</div>

Hi everybody,

I am trying to parse a json in order to have a nested field in my docu but I get the following message:  
Error parsing json {:source=\>"catejories\_json", :raw=\>#Java::OrgPostgresqlUtil::PGobject:0x54047773, :exception=\>java.lang.ClassCastException: org.jruby.java.proxies.ConcreteJavaProxy cannot be cast to org.jruby.RubyIO, :level=\>:warn}

the data that I use is:  
customer == \> type string  
catejories\_json ==\> type json

customer  
1

catejories\_json  
[{"first\_level":592,"second\_level":[20521]},{"first\_level":335,"second\_level":null},{"first\_level":380,"second\_level":null},{"first\_level":661,"second\_level":null},{"first\_level":391,"second\_level":[662,20277]}]

the config file for logstash:  
input {  
jdbc {  
jdbc\_connection\_string =\> "jdbc:postgresql://myhost:5432/mydb"  
jdbc\_user =\> "postgres"  
jdbc\_password =\> "mypasword"  
jdbc\_validate\_connection =\> true  
jdbc\_driver\_library =\> "/usr/share/elasticsearch/lib/postgresql-9.4.1208.jar"  
jdbc\_driver\_class =\> "org.postgresql.Driver"  
statement =\> "SELECT customer, catejories\_json FROM customers WHERE customer = '1' "  
jdbc\_paging\_enabled =\> "true"  
jdbc\_page\_size =\> "50000"  
}  
}

filter {  
json {  
source =\> "catejories\_json"  
target =\> "categories\_obj"  
remove\_field =\> ["catejories\_json"]  
}  
}

output {  
elasticsearch{  
index =\> "test"  
document\_type =\> "type\_test"  
document\_id =\> "customer"  
}  
}  
and the mapping is:  
POST test/  
{  
"mappings": {  
"type\_test": {  
"properties": {  
"customer": {  
"type": "string"  
},  
"categories\_obj": {  
"type": "nested",  
"properties": {  
"first\_level": {  
"type": "integer"  
},  
"second\_level": {  
"type": "integer"  
}  
}  
}  
}  
}  
}  
}

I have use [http://jsonlint.com/](http://jsonlint.com/) to test the json field and the result is successful.  
I have install: codec-multiline and off course json filter.

In advance, thousands thanks for your support.

Regards,

Jorge von Rudno

---

<div class="post-metadata">

**Author:** ![Axel.Walsleben](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@Axel.Walsleben](https://discuss.elastic.co/u/Axel.Walsleben)\
**Post date:** [May 16, 2017, 1:29pm UTC](https://discuss.elastic.co/t/error-parsing-json-using-jdbc-input/48954/2 "2017-05-16T13:29:25Z")

</div>

Cast your Resultfield to Text.  
Like:  
SELECT customer, catejories\_json::text FROM customers WHERE customer = '1'

This works for me.

---

<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:26am UTC](https://discuss.elastic.co/t/error-parsing-json-using-jdbc-input/48954/3 "2017-07-06T04:26:32Z")

</div>


