1

Mandrill sends back JSON data to my web-hook and when converted to Ruby data structures it looks like the below:

{ "image.jpg" => { "name => "image.jpg", "type" => "image/jpeg", "content" => "", "base64" => true } }

They send this, when what I need is an Array of Hashes, ex:

[{ "name => "image.jpg", "type" => "image/jpeg", "content" => "", "base64" => true }]

How can the first set of data be converted to an array of hashes?

1 Answer 1

2

Try setting the returned data to foo:

foo = { "image.jpg" => { "name" => "image.jpg", "type" => "image/jpeg", "content" => "", "base64" => true } }

Then do:

Array.wrap(foo["image.jpg"])

Also, you're missing a closing quote symbol after the first "name" key in your hash

Edit: You can just set it to foo then run:

foo.values
Sign up to request clarification or add additional context in comments.

1 Comment

It needs to be dynamic, can't statically use "image.jpg" because it will differ.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.