# Convert column to JSON

**URL:** <https://discuss.elastic.co/t/convert-column-to-json/158848>\
**Category:** Logstash\
**Created:** [November 30, 2018, 4:55am UTC](https://discuss.elastic.co/t/convert-column-to-json/158848 "2018-11-30T04:55:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nash](https://avatars.discourse-cdn.com/v4/letter/n/91b2a8/32.png) [@nash](https://discuss.elastic.co/u/nash)\
**Post date:** [November 30, 2018, 4:55am UTC](https://discuss.elastic.co/t/convert-column-to-json/158848/1 "2018-11-30T04:55:15Z")

</div>

Hi,  
I am new to ELK.  
I am trying to import a CSV file into elasticsearch using Logstash.I have got all the fields into elasticSearch and it is of type doc.

I can see it in both Table and json formats.

My problem is, one of the fields contains multiple sub fields, I want to parse them as Jason. For example  
Brand:Honda, car: "City", year:"2002", Engine:"1.5L",Dimensions:"{Length:"300cm", Breadth:"180cm", Height"150cm"}"

The Dimensions is shown as a string and not as a JSON. Is there any way to parse Dimensions as JSON using logstash filters.  
The current conf file looks like this.  
input {

```
    file {
    path => "C:/program files/logstash-6.5.1/data/raw.csv"
    start_position => "beginning"
	  sincedb_path => "nul"
    codec => "json"
  }
filter {
      csv {
        separator => ","
        columns => ["Brand","Car","year","Dimensions"]
      }
      json {
        source => ["Dimensions"]
      }
}
output {

elasticsearch {

hosts =&gt; ["http://localhost:9200"]

index =&gt; ["dermapenexperimentjson"]

manage_template =&gt; false

}

stdout {codec =&gt; rubydebug}

}

```

Now this script runs, but Dimensions is still shown as string in Elasticsearch not as a Json.

I get the following error if I try to introduce a json filter for Dimensions in config file.

> :error=\>#\<LogStash::Json::ParserError: incompatible json object type=java.lang.String , only hash map or arrays are supported

---

<div class="post-metadata">

**Author:** ![Eniqmatic](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Eniqmatic](https://discuss.elastic.co/u/Eniqmatic)\
**Post date:** [November 30, 2018, 8:13am UTC](https://discuss.elastic.co/t/convert-column-to-json/158848/2 "2018-11-30T08:13:51Z")

</div>

Can you post a proper example of your JSON? The one you posted above is not valid JSON.

---

<div class="post-metadata">

**Author:** ![balumurari1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/balumurari1/32/39203_2.png) [@balumurari1](https://discuss.elastic.co/u/balumurari1)\
**Post date:** [December 5, 2018, 10:25am UTC](https://discuss.elastic.co/t/convert-column-to-json/158848/3 "2018-12-05T10:25:52Z")

</div>

hope this helps you,

> [@Load csv file in logstash](https://discuss.elastic.co/t/load-csv-file-in-logstash/151319/3):
>
> Thanks for reply,hope this works fine, input { file { path =\> "D:/Balu/ELK-stack/csvfile.csv" start\_position =\> "beginning" sincedb\_path =\> "NUL" } } filter { csv { separator =\> "," columns =\> ["open","high","low","close","volume"] } } output { elasticsearch { hosts =\> "[http://localhost:9200](http://localhost:9200)" index =\> "wallet-address-index" } stdout { codec =\> rubydebug } }

---

<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:** [January 2, 2019, 10:30am UTC](https://discuss.elastic.co/t/convert-column-to-json/158848/4 "2019-01-02T10:30:01Z")

</div>

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