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>
This commit is contained in:
Ronald Barendse
2024-04-10 20:21:24 +02:00
committed by GitHub
parent 1c5e27397b
commit 16dd5327d4
33 changed files with 495 additions and 332 deletions

View File

@@ -1,5 +1,7 @@
namespace Umbraco.Cms.Core.Serialization;
/// <summary>
/// Provides functionality to serialize objects or value types to JSON and to deserialize JSON into objects or value types, used for data type configuration.
/// </summary>
public interface IConfigurationEditorJsonSerializer : IJsonSerializer
{
}
{ }

View File

@@ -1,8 +1,27 @@
namespace Umbraco.Cms.Core.Serialization;
/// <summary>
/// Provides functionality to serialize objects or value types to JSON and to deserialize JSON into objects or value types.
/// </summary>
public interface IJsonSerializer
{
/// <summary>
/// Converts the specified <paramref name="input" /> into a JSON string.
/// </summary>
/// <param name="input">The input.</param>
/// <returns>
/// A JSON string representation of the value.
/// </returns>
string Serialize(object? input);
/// <summary>
/// Parses the text representing a single JSON value into an instance of the type specified by a generic type parameter.
/// </summary>
/// <typeparam name="T">The target type of the JSON value.</typeparam>
/// <param name="input">The JSON input to parse.</param>
/// <returns>
/// A <typeparamref name="T" /> representation of the JSON value.
/// </returns>
T? Deserialize<T>(string input);
}