Typed JSON serialization of case classes