Files
Umbraco-CMS/src/Umbraco.Infrastructure/Serialization/JsonStringInternConverter.cs
Ronald Barendse 16dd5327d4 v14: Refactor and enhance System.Text.Json converters (#15960)
* Update JsonUdiConverter to support Udi, GuidUdi and StringUdi types

* Require boolean (like) value and rename to JsonFuzzyBooleanConverter

* Add read/write only JsonConverters and align naming

* Rename SystemTextJsonSerializer to DefaultJsonSerializer

* Rename SystemTextConfigurationEditorJsonSerializer to DefaultConfigurationEditorJsonSerializer

* Add JsonUdiRangeConverter

* Rename JsonFuzzyBooleanConverter back to JsonBooleanConverter

* Fix value type check in JsonObjectConverter

* Revert class names

* Updated tests

* Post fix after merge.

---------

Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2024-04-10 20:21:24 +02:00

16 lines
490 B
C#

using System.Text.Json;
namespace Umbraco.Cms.Infrastructure.Serialization;
/// <summary>
/// Converts a string to or from JSON, interning the string when reading.
/// </summary>
public sealed class JsonStringInternConverter : ReadOnlyJsonConverter<string>
{
/// <inheritdoc />
public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
=> reader.GetString() is string value
? string.Intern(value)
: null;
}