Taking result in json, and sending it to a txt

Guys, I currently have a result in json, that way.

[
  %{
    virtual_params: "Message 1"
  },
  %{
    virtual_params: "Message 2"
  },
  %{
    virtual_params: "Message 3"
  },
  %{
    virtual_params: "Message 4"
  }
]

How do I write the result of this virtual_params in a text file (* .txt)?

Note: Must have line break(\n).

Is there any way?

You mean something like:

File.write!("file.txt", Enum.map(map, &[&1.virtual_params, ?\n]))
2 Likes