How to derive Jason.Encoder in Livebook
11 February 2025
I ran into the issue of trying to include @derive Jason.Encoer
in a struct while working Livebook.
My code was simple enough:
defmodule ContentPart do
@derive Jason.Encoder
defstruct [:text]
end
but I was getting a warning:
warning: the Jason.Encoder protocol has already been consolidated, an implementation for ContentPart has no effect.
I found a simple fix in a comment by Wojtek Mach:
Mix.install([:jason], consolidate_protocols: true)