mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-09-13 02:50:37 +00:00
Fixed JSON serialization of enums to use member names
This commit is contained in:
parent
2b3901ac32
commit
e872b16067
@ -22,6 +22,14 @@ internal static class VisualBriefingJson
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the shared JSON configuration.
|
/// Creates the shared JSON configuration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Enums are written as their member names instead of numbers. Stored briefings outlive many
|
||||||
|
/// releases, so a numeric value would silently change meaning as soon as somebody inserts or
|
||||||
|
/// reorders an enum member. Most visual briefing enums carry the converter as an attribute
|
||||||
|
/// already; this option covers the ones defined outside the feature, such as the target language
|
||||||
|
/// and the audience enums. Reading still accepts numbers, so briefings written before this
|
||||||
|
/// change keep loading.
|
||||||
|
/// </remarks>
|
||||||
/// <param name="writeIndented">Whether serialized JSON should be indented.</param>
|
/// <param name="writeIndented">Whether serialized JSON should be indented.</param>
|
||||||
/// <returns>The configured serializer options.</returns>
|
/// <returns>The configured serializer options.</returns>
|
||||||
private static JsonSerializerOptions Create(bool writeIndented) => new()
|
private static JsonSerializerOptions Create(bool writeIndented) => new()
|
||||||
@ -31,5 +39,6 @@ internal static class VisualBriefingJson
|
|||||||
WriteIndented = writeIndented,
|
WriteIndented = writeIndented,
|
||||||
Encoder = JavaScriptEncoder.Default,
|
Encoder = JavaScriptEncoder.Default,
|
||||||
UnmappedMemberHandling = JsonUnmappedMemberHandling.Disallow,
|
UnmappedMemberHandling = JsonUnmappedMemberHandling.Disallow,
|
||||||
|
Converters = { new JsonStringEnumConverter() },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user