# Logstash 2.3.3 convert integers in list of json

**URL:** https://discuss.elastic.co/t/logstash-2-3-3-convert-integers-in-list-of-json/74089
**Category:** Logstash
**Created:** [February 6, 2017, 3:56pm UTC](https://discuss.elastic.co/t/logstash-2-3-3-convert-integers-in-list-of-json/74089 "2017-02-06T15:56:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![misomij](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/misomij/32/10700_2.png) [@misomij](https://discuss.elastic.co/u/misomij)
#### Post date: [February 6, 2017, 3:56pm UTC](https://discuss.elastic.co/t/logstash-2-3-3-convert-integers-in-list-of-json/74089/1 "2017-02-06T15:56:02Z")

</div>

Hi all,

I have a parsing problem with Logstash 2.3.3  
I haven't found similar questions, apologize if this is a duplicate.  
As input I have a file which every like is a json similar to this:

```
  {
    "field1": "foo",
    "field2": "100",
    "test":[
        {
            "name": "bar",
            "count":"13"
        },
        {
            "name": "asd",
            "count":"15"
        },
        {
            "name": "lol",
            "count":"7"
        }
    ],
    "field3": "300"
  }

```

I have the need to convert the string/numeric fields in integers. I use this configuration:

```
input {
  file {
    path => ["/path/to/file.json"]
    sincedb_path => "/path/to/db"
    start_position => "beginning"
    type => "foo"
    codec => "json"
  }
}

filter {
  if [type] == "foo" {
    mutate {
      convert => { "field2" => "integer" }
      convert => { "[test][count]" => "integer" }
      convert => { "field3" => "integer" }
    }
 ...
}

output {
  if [type] == "foo" {
    elasticsearch {
      hosts => ["127.0.0.1:9200"]
      index => "logstash-test"
    }
  }
}

```

The conversion on `field2` and `field3` is working correctly, the one on`[test][count]` no.  
I can understand why this is not working, I am searching for a `count` field inside `test` and that key does not exist in `test`. I don't get any error by Logstash.  
I can't find a solution, any idea?  
Any help is appreciated.

Thanks!

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [February 7, 2017, 8:46am UTC](https://discuss.elastic.co/t/logstash-2-3-3-convert-integers-in-list-of-json/74089/2 "2017-02-07T08:46:22Z")

</div>

I think you need to use a ruby filter for this kind of conversion.

---

<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: [March 7, 2017, 8:46am UTC](https://discuss.elastic.co/t/logstash-2-3-3-convert-integers-in-list-of-json/74089/3 "2017-03-07T08:46:38Z")

</div>

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