# Filtering nested json outupt

**URL:** <https://discuss.elastic.co/t/filtering-nested-json-outupt/186765>\
**Category:** Logstash\
**Created:** [June 20, 2019, 8:51pm UTC](https://discuss.elastic.co/t/filtering-nested-json-outupt/186765 "2019-06-20T20:51:29Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 20, 2019, 9:31pm UTC](https://discuss.elastic.co/t/filtering-nested-json-outupt/186765/4 "2019-06-20T21:31:38Z")

</div>

```
    ruby {
        code => '
            a = []
            event.get("d").each { |x|
                h = {}
                h["commit"] = x["commit"]
                h["created_at"] = x["created_at"]
                a << h
            }
            event.set("someField", a)
        '
    }

```

will get you

```
 "someField" => [
    [0] {
        "created_at" => "2019-06-19T00:27:28.107Z",
            "commit" => "9d6542006b3b9a3d61994e24f9d1c6dc"
    },
    [1] {
        "created_at" => "2019-06-18T23:10:13.653Z",
            "commit" => "dec59d2b05c5db9a7d4d90bfaab27e3b"
    },
    [2] {
        "created_at" => "2019-06-12T18:22:53.281Z",
            "commit" => "2200c40d0972f4fe25bba661e7945112"
    }
```

---

_[View the full topic](https://discuss.elastic.co/t/filtering-nested-json-outupt/186765)._
