I think virtual fields are a good use case for it,
For instance:
defimpl Jason.Encoder, for: WhateverSchema do
def encode(struct, opts) do
struct
|> Map.put(:avatar, RunTimeSettings.get_url_for(struct))
# |> maybe_trim_private_fields()
|> Jason.Encode.map(opts)
end
end
Personally, if the full url is the only thing that makes sense for the client(s), I replace the field itself with the valid url, if the client needs/can use the field value for something, I define a virtual field and then populate that instead.


















