tovarchristian21
Hello guys, can you please help turn this map into a pure map. Some of the members of the map are still structs.
%{
callback_query: nil,
channel_post: nil,
chosen_inline_result: nil,
edited_message: nil,
inline_query: nil,
message: %Nadia.Model.Message{
audio: nil,
caption: nil,
channel_chat_created: nil,
chat: %Nadia.Model.Chat{
first_name: "Christian",
id: 543211234,
last_name: "Tovar",
photo: nil,
title: nil,
type: "private",
username: "ChristianTovar"
},
contact: nil,
date: 1562605521,
delete_chat_photo: nil,
document: nil,
edit_date: nil,
entities: nil,
forward_date: nil,
forward_from: nil,
forward_from_chat: nil,
from: %Nadia.Model.User{
first_name: "Christian",
id: 543211234,
last_name: "Tovar",
username: "ChristianTovar"
},
group_chat_created: nil,
left_chat_member: nil,
location: nil,
message_id: 714,
migrate_from_chat_id: nil,
migrate_to_chat_id: nil,
new_chat_member: nil,
new_chat_photo: [],
new_chat_title: nil,
photo: [],
pinned_message: nil,
reply_to_message: nil,
sticker: nil,
supergroup_chat_created: nil,
text: "google meets",
venue: nil,
video: nil,
voice: nil
},
update_id: 412827321
}
Trending in Questions
One of my LiveView view’s has a very heavy javascript dependency so I want to avoid loading it for every page on the site, while still us...
New
Hi all!
I know that quite a few people use Phoenix LiveView but it is hard to get a more up-to-date list of folks/companies using it. I ...
New
I have a page in my Phoenix app with some LiveView code. When you click a button, it shows the Stripe credit card modal form via a Hook. ...
New
Hello everyone!
I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++.
Does anyone ...
New
I’m very new to Elixir, so sorry if this is a silly question:
I am wondering what happens to the mailbox of a process when the machine i...
New
I load tested a plain Phoenix chat app backed by Postgres with 100 million messages in it, everything on default settings, to see what br...
New
Background
When trying to execute mix release on a Windows 11 machine for a Phoenix project I get the following error:
* assembling mark...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hi everyone :waving_hand:
I’ve been working on PhiaUI, an open-source UI component library for Phoenix LiveView, and I wanted to share i...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #elixirconf-us
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #elixirconf-eu
- #security
- #processes
- #api
- #forms
- #hex











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
wolfiton
Hello,
Welcome to the forum
This may help you
from_struct(struct)View Source
from_struct(atom() | struct()) :: map()
Converts a
structto map.It accepts the struct module or a struct itself and simply removes the
__struct__field from the given struct or from a new struct generated from the given module.Example
tovarchristian21
I actually did that for the outer map. It was a struct, however that function does not turn inner struct into maps…
NobbZ
You need to implement the nesting on your own. But that is a lot more expensive, as it needs to reconstruct the maps from scratch
wolfiton
Wouldn’t s/he be able to use
Like this?
Also if i am mistaken please correct me(still learning to think in elixir and the language)
NobbZ
No,
Enum.each/2returns:ok. Also you need to decide for each key in the map/struct if you want to convert it or not.Eiji
Here is example working code:
Please let me know if you have any questions.
Related documentation:
tovarchristian21
Outstanding! Bravo! Thanks for the help, very complete module indeed.
idi527
Why do you want to convert these structs to maps? Maybe there’s an easier way to accomplish what you want … Personally, I don’t remember having problems with
:nadia’s structs.elielhaouzi
We write a lib of utils around ecto https://github.com/annatel/antl_utils_ecto
one of the functionality is
AntlUtilsEcto.map_from_struct(my_schema)dodul
The simplest solution that I found is using Poison.