Custom serializer for blocks