How to accept json object and store in a file

I’m new to elixir. I want to create an input and output function which will take a JSON object and store it in a file? Storage can be document storage just like MongoDB.

I’m not using phoenix. Just elixir

This is a very general question.

Something like…

def serialize_to_db(key, val) do
    Jason.encode!(val) |> SomeStorageDrive.put(key, val)
end

Should work?

You could perform some sort of error handling or whatever else

1 Like