Parsing Array in to Elasticsearch

We're looking to parse an array into Elasticsearch but I'm struggling to write some Ruby code to convert it into the way that I want.

The raw data looks like this

"marketingPreferences" => {
                        "updatedDate" => "2019-02-19T22:33:17.5779143+00:00",
                            "default" => [
            [0] {
                   "isAllowed" => false,
                "deliveryType" => "Mail"
            },
            [1] {
                   "isAllowed" => false,
                "deliveryType" => "Phone"
            },
            [2] {
                   "isAllowed" => false,
                "deliveryType" => "SMS"
            },
            [3] {
                   "isAllowed" => true,
                "deliveryType" => "Email"
            }
        ],
        "marketingPreferencesVersion" => "V2"
    }

I would eventually like it to look like

[marketingPreferences][Mail] => false
[marketingPreferences][Phone] => false
[marketingPreferences][SMS] => false
[marketingPreferences][Email] => true

etc...

Any idea on a bit of ruby code that can do this?

Does this help?

Amazing!

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