How can I use JsonConverterFactory in System.Text.Json

william-j wrote on 7/1/2024, 7:49 AM

I'm creating VEGAS Custom Command with System.Text.Json, and trying to process some JSON data using a custom JSON converter for my class.

As long as I declare:

using System.Text.Json;
using System.Text.Json.Serialization;

public class MyConverterFactory : JsonConverterFactory {
    public override bool CanConvert(Type typeToConvert) {
        return true;
    }

    public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) {
        return (JsonConverter)Activator.CreateInstance(typeToConvert);
    }
}

My extension disappears from VEGAS. That is, if a class extends to JsonConverterFactory, VEGAS cannot use it. After removing it, it can be used.

Comments

No comments yet - be the first to write a comment...