Skip to content

Commit

Permalink
Move settings into ContentSerializerJsonOptionsConfiguration.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Mar 18, 2024
1 parent 2f0f2c8 commit 3d63542
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public ContentSerializerJsonOptionsConfiguration(IOptions<JsonDerivedTypesOption

public void Configure(ContentSerializerJsonOptions options)
{
options.SerializerOptions.PreferredObjectCreationHandling = JsonObjectCreationHandling.Populate;
options.SerializerOptions.ReferenceHandler = null; // Needed by JsonObjectCreationHandling.Populate.

options.SerializerOptions.DefaultIgnoreCondition = JOptions.Base.DefaultIgnoreCondition;
options.SerializerOptions.ReferenceHandler = JOptions.Base.ReferenceHandler;
options.SerializerOptions.ReadCommentHandling = JOptions.Base.ReadCommentHandling;
options.SerializerOptions.PropertyNameCaseInsensitive = JOptions.Base.PropertyNameCaseInsensitive;
options.SerializerOptions.AllowTrailingCommas = JOptions.Base.AllowTrailingCommas;
Expand Down
3 changes: 1 addition & 2 deletions src/OrchardCore/OrchardCore.Abstractions/Json/JOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public static class JOptions
public static readonly JsonSerializerOptions Base = new()
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
PreferredObjectCreationHandling = JsonObjectCreationHandling.Populate,
ReferenceHandler = null, // Needed by JsonObjectCreationHandling.Populate.
ReferenceHandler = ReferenceHandler.IgnoreCycles,
ReadCommentHandling = JsonCommentHandling.Skip,
PropertyNameCaseInsensitive = true,
AllowTrailingCommas = true,
Expand Down

0 comments on commit 3d63542

Please sign in to comment.