That should read triple nested Enum.each ****
On Wednesday, July 27, 2016 at 2:42:43 PM UTC+10, Sam Hains wrote:
>
> Hey Elixir-Lang-Talk!
>
>
> I have a question about dealing with complicated API requests in a
> functional way. If we are given a JSON response that looks something like
> this:
>
>
> {
>
> “room_id1”: {
> “date1”: {
> “id”: "3",
> “other_variables”: 1,
> “other_variables”: 2,
> “important_stuff”: {
> “id”: “2342”,
> “child_id1”: {
> “var1”: 1,
> “var2”: 1,
> “var3”: true,
>
> },
>
> “child_id2”: {
> “var1”: 2,
> “var2”: 2,
> “var3”: true,
>
> },…
>
> }
>
> }
>
>
>
> and we want to take information held in the keys and place it in the inner
> most object (i’ve called it important stuff). Such that the final data
> looks like this:
>
>
> [{
>
> room_id: “room_id1”,
> date: “date1”,
> child_id: “child_id1”,
> var1: 1,
> var2: 1,
> var3: true
>
> },
>
> {
>
> room_id: “room_id2”,
> date: “date2”,
> child_id: “child_id2”,
> var1: 2,
> var2: 2,
> var3: true
>
> }]
>
>
>
>
> How might we manage this in a functional way, without side effects? At the
> moment, I have triple nested Enums, building the object which is then
> inserted directly into a database via Ecto. I would really like to separate
> the transforming of the API data with the inserting of that data in the
> database.
>
> Thanks,
> Sam
>
>
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-talk/45e44533-b545-40e5-a8c6-fe5b70323943%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.