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

New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
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
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
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31013 112
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43757 214
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31265 143
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement