Converting an Elixir list into a Python dictionary

What libraries, if any, can be used to take an Elixir list: [color: "Red", make: "Mclaren", mileage: 15641.469] and convert into a Python dictionary - {"color": "Red", "make": "Mclaren", "mileage": 15641.469}?

If no such libraries exist, what approach would you recommend to accomplish this efficiently?

What you mean by “convert”? If you want to send it to the other program then you need to serialise it into some format understood by the both parties and then send it. For example you can use JSON, BARE, ProtoBuf, bencode, ETF, Cap’n’proto or almost any other format out there.

3 Likes

Got it! Which is the more noob friendly approach? :slight_smile:

That python example looks like json

iex(2)> [color: "Red", make: "Mclaren", mileage: 15641.469] |> Map.new |> Jason.encode!
"{\"color\":\"Red\",\"make\":\"Mclaren\",\"mileage\":15641.469}"
3 Likes

You could probably look for some ETF library for Python. Not sure if there are any though.

1 Like