How to encode ecto schema with Jason with all fields

You’ve tagged this with Phoenix which makes me think you’re doing this in order to render a schema for an API. The suggested approach is to not do this with encoder protocols but rather with JSON views: JSON Views in Phoenix | RokkinCat