Filtering nested json outupt

    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"
    }
1 Like