Fl4m3Ph03n1x

Fl4m3Ph03n1x

Is there a way to get Keyword in key is String and not atom?

Background

I have a Keywords list I got from HTTPoison that looks like this:

        [
          {"Date", "Tue, 10 Jan 2023 09:47:09 GMT"},
          {"Content-Type", "text/html; charset=utf-8"},
          {"Transfer-Encoding", "chunked"},
          {"Connection", "keep-alive"},
          {"set-cookie",
           "JWT=some_cookie; Domain=.mywebsite; Expires=Sat, 11-Mar-2023 09:47:09 GMT; Secure; HttpOnly; Path=/; SameSite=Lax"},          {"x-frame-options", "sameorigin"},
          {"strict-transport-security", "max-age=2592000; includeSubDomains; preload"},
          {"CF-Cache-Status", "DYNAMIC"},
          {"X-Content-Type-Options", "nosniff"},
          {"Server", "cloudflare"}
        ]

To me, this looks like a Keyword, however, the keys are Strings and not atoms, thus I cannot use the Keyword.get/3 function nor any of its friends.

Question

What is the Elixir way of getting the a value from this keyword list?

Marked As Solved

cmo

cmo

List.keyfind

Also Liked

LostKobrakai

LostKobrakai

The definition for an (elixir) keyword list is a list of 2-tuples, where the first element is an atom. So what you got here is not a keyword list and therefore Keyword APIs are not supposed to work for that list. There are however some useful functions in List.key* or in erlangs :proplists.

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
logicmason
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

We're in Beta

About us Mission Statement