Showing specific fields in json (List)

Guys, I’m currently trying to get only the field (text) that contains the value “Period”, but I’m not getting it.
can you help me?

fields = Enum.map(json_atoms.messages, &%{v_priority: &1[:blocks] |> Enum.at(0) |> Access.get(:fields)})

Result:

[
  %{
    v_priority: [
      %{text: "*Prioridade:*\nTest1", type: "mrkdwn", verbatim: false},
      %{text: "*Origem:*\nTest2", type: "mrkdwn", verbatim: false},
      %{text: "*Period:*\n28/12 21:59", type: "mrkdwn", verbatim: false},
      %{text: "*Number:*\n0000000", type: "mrkdwn", verbatim: false}
    ]
  },
  %{
    v_priority: [
      %{text: "*Prioridade:*\nTest2", type: "mrkdwn", verbatim: false},
      %{text: "*Origem:*\nTest3", type: "mrkdwn", verbatim: false},
      %{text: "*Period:*\n29/12 21:59", type: "mrkdwn", verbatim: false},
      %{text: "*Number:*\n0000000", type: "mrkdwn", verbatim: false}
    ]
  }
]

I tried with Enum.filter, but to no avail.

Could you:

  1. Describe what you are trying to achieve, not what you have done to achieve it.
  2. Provide us with minimal example input.
  3. Provide us with minimal example of expected output for input from step 2.
1 Like