aronteh

aronteh

List of nested maps help

Hi, I have the following nested map below:

ordered_contents =[
  %{
    "order_id" => 1234567,
    "version" => 24,
    "content" => [
      %{
        "contents" => [
          %{
            "id" => "551546104",
            "level" => "",
            "quantity" => 340,
            "random" => true,
            "type" => "resource"
          },
          %{
            "id" => "229186523",
            "level" => "",
            "quantity" => 15,
            "random" => true,
            "type" => "resource"
          }
        ],
        "id" => 2323110,
        "name" => "RSS Gold",
        "type" => "U",
        "version" => 24
      }
    ]
  },
  %{
    "order_id" => 1234568,
    "version" => 24,
    "content" => [
      %{
        "contents" => [
          %{
            "id" => "551546104",
            "level" => "",
            "quantity" => 300,
            "random" => true,
            "type" => "resource"
          },
          %{
            "id" => "229186523",
            "level" => "",
            "quantity" => 40,
            "random" => true,
            "type" => "resource"
          }
        ],
        "id" => 2323110,
        "name" => "RSS Silver",
        "type" => "U",
        "version" => 24
      }
    ]
  }
]

I am new to Elixir, how do I flatten the map to read all the map value or there any shorter way?

First Post!

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Welcome! When you say “read all the map values” what do you have in mind? Can you provide an example of the kind of data you’re looking to generate from that input?

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 55125 245
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement