While serializing a VL object which is using an interface, or using a spread of object, the json serializer preserves the data type information. There is a $type in there which is a problem for a 3rd party service to parse it!
Is there a way to remove that $type during serialization?
There’s no such switch / option in message pack to change that to my knowledge. So here are your options:
A) Write your own serializer.
B) Get rid of the IContent/TextContent/ImageContent and use one Content record with the fields as you outlined.
C) Do some post-string processing or JSON processing and remove that line/JSON property
Thinking of the option B; having one Content record would be the best, indeed.
However, although the types are all string, for the serialization, once I would need a pad called “text“ and once “image_url“.
I was wondering if there is a way to do something similar:
public class Content
{
[JsonPropertyName(“image_url”)]
public string Content { get; set; }
public string Type { get; set;}
}
Two pads, one named “image_url” one “text”. In the serialization you’ll probably see both with one of them empty.
Having an attribute to have a different name for the pads in json would be nice indeed. To my understanding the json serializer internally uses message pack, not sure that one supports that.