Generate JSON instances for entities

Enable automatic generation of ToJSON and FromJSON instances. Add custom
settings for JSON decoding and encoding of entities.

Signed-off-by: Stian Ellingsen    <stian@plaimi.net>
Signed-off-by: Alexander Berntsen <alexander@plaimi.net>
Reviewed-by:   Alexander Berntsen <alexander@plaimi.net>