I've got an interesting situation whereby elastic v7 default utf8json has managed to serialize my object, but is unable to de-serialize it correctly.
public class MyClass : FlagsSet
{
[JsonIgnore]
public bool IsActive
{
get
{
return this.IsSet("active");
}
}
}
public class FlagsSet : ICollection<string>, IEnumerable<string>, IEnumerable
{
private readonly HashSet<string> _list = new HashSet<string>((IEqualityComparer<string>) StringComparer.InvariantCultureIgnoreCase);
...
public void Add(string item)
{
if (string.IsNullOrEmpty(item))
return;
this._list.Add(item);
}
}
If I was using json.net I'd handle this by writing a converter, but I'm not able to see an equivalent using utf8json as it appears the formatters used by the default serializer (DefaultHighLevelSerializer) are all registered internally. I've read a few pages on customer serializers (notably this one.. https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/custom-serialization.html)
So in short..
- Is it possible to register a custom utf8json formatter (i.e. similar to the json.net converter which is supported)? And if so, are you able to point me to an example please?
- Alternatively, if it's not possible then is there a way to get the utf8json deserialisation to work correctly with the above example?