# How to split a JSON array inside an object

**URL:** <https://discuss.elastic.co/t/how-to-split-a-json-array-inside-an-object/25511>\
**Category:** Logstash\
**Created:** [July 14, 2015, 10:08am UTC](https://discuss.elastic.co/t/how-to-split-a-json-array-inside-an-object/25511 "2015-07-14T10:08:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joerno](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@joerno](https://discuss.elastic.co/u/joerno)\
**Post date:** [July 14, 2015, 10:08am UTC](https://discuss.elastic.co/t/how-to-split-a-json-array-inside-an-object/25511/1 "2015-07-14T10:08:25Z")

</div>

I have a JSON-Message with an array in an array. I want to split that into multiple events (because of kibana):

```
{
"type": "monitor",
"server": "10.111.222.333",
"host": "abc.de",
"bean": [{
    "name": "beanName1",
    "reseted": "2015-06-05T15:10:00.192Z",
    "method": [{
      "name": "getAllXY",
      "count": 5,
      "min": 3,
      "max": 5
    },
    {
      "name": "getName",
      "count": 4,
      "min": 2,
      "max": 4
    }]
  },
  {
    "name": "beanName2",
    "reseted": "2015-06-05T15:10:00.231Z",
    "method": [{
      "name": "getProperty",
      "count": 4,
      "min": 3,
      "max": 3
    }]
  },
  {
    "name": "beanName3",
    "reseted": "2015-06-05T15:10:00.231Z"
  }]
}

```

Using a filter to split "bean":

```
input {
  stdin {
    codec => "json"
  }
}

filter {
  split {
    field => "bean"
  }
}

output {
  stdout{codec => "json"}
}

```

is working well:

```
{"type":"monitor",
    "server":"10.111.222.333",
     "host":"abc.de",
 "bean":{
   "name":"beanName1",
   "reseted":"2015-06-05T15:10:00.192Z",
   "method":[{
     "name":"getAllXY",
     "count":5,
     "min":3,
     "max":5 
    },{
     "name":"getName",
     "count":4,
     "min":2,
     "max":4
    }]},
 "@version":"1",
 "@timestamp":"2015-07-14T09:21:18.326Z"
}

{"type":"monitor",
 "server":"10.111.222.333",
 "host":"abc.de",
 "bean":{
   "name":"beanName2",
   "reseted":"2015-06-05T15:10:00.231Z",
   "method":[{
     "name":"getProperty",
     "count":4,
     "min":3,
     "max":3
   }]},
 "@version":"1",
 "@timestamp":"2015-07-14T09:21:18.326Z"
}

    ...

```

To seperate also the "methods", I added another split-filter:

```
  split {
    field => "bean"
  }
  split {
    field => "bean.method"
  }

```

But that way I get only an error message:

> Exception in filterworker {"exception"=\>#LogStash::ConfigurationError: Only String and Array types are splittable. field:bean.method is of type = NilClass

I can't access the array "method" inside the object "bean". I tried different notations with no luck. Is it possible to access the array, maybe it isn't supported yet?

(I posted the question also at stackoverflow)

---

<div class="post-metadata">

**Author:** ![bradley.bristowstagg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bradley.bristowstagg/32/9954_2.png) [@bradley.bristowstagg](https://discuss.elastic.co/u/bradley.bristowstagg)\
**Post date:** [November 23, 2016, 1:05am UTC](https://discuss.elastic.co/t/how-to-split-a-json-array-inside-an-object/25511/2 "2016-11-23T01:05:13Z")

</div>

This was asked and answered here: [http://stackoverflow.com/questions/31402997/how-to-split-a-json-array-inside-an-object](http://stackoverflow.com/questions/31402997/how-to-split-a-json-array-inside-an-object)

---

<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:30am UTC](https://discuss.elastic.co/t/how-to-split-a-json-array-inside-an-object/25511/3 "2017-07-06T04:30:17Z")

</div>


