diff --git a/Server/Components/AICore/Context/SummaryParser/JsonContextSummaryParser.cs b/Server/Components/AICore/Context/SummaryParser/JsonContextSummaryParser.cs index 9650fbfda..a3f04528b 100644 --- a/Server/Components/AICore/Context/SummaryParser/JsonContextSummaryParser.cs +++ b/Server/Components/AICore/Context/SummaryParser/JsonContextSummaryParser.cs @@ -12,26 +12,18 @@ namespace AICore.Context.SummaryParser { internal class JsonContextSummaryParser : BaseContextSummaryParser { + private readonly JsonSerializerOptions JsonOptions = new JsonSerializerOptions() + { + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + IncludeFields = true, + }; + public override string Parse(AiActionType actionType, IContextSummary context) { - var options = new JsonSerializerOptions { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, IncludeFields = true }; + if (context is null) + return "{}"; - var json = "{}"; - - if(context is ServiceRecordDocumantationFCS fcs) - { - json = JsonSerializer.Serialize(fcs, options); - } - else if(context is ServiceRecordNavigationCS ncs) - { - json = JsonSerializer.Serialize(ncs, options); - } - else - { - json = JsonSerializer.Serialize(context, options); - } - - return json; + return JsonSerializer.Serialize(context, context.GetType(), JsonOptions); } } }