using System.Diagnostics.CodeAnalysis; namespace Umbraco.Cms.Core.Serialization; /// /// Provides functionality to serialize objects or value types to JSON and to deserialize JSON into objects or value types. /// public interface IJsonSerializer { /// /// Converts the specified into a JSON string. /// /// The input. /// /// A JSON string representation of the value. /// string Serialize(object? input); /// /// Parses the text representing a single JSON value into an instance of the type specified by a generic type parameter. /// /// The target type of the JSON value. /// The JSON input to parse. /// /// A representation of the JSON value. /// T? Deserialize(string input); /// /// Attempts to parse an object that represents a JSON structure - i.e. a JSON object or a JSON array - to a strongly typed representation. /// /// The target type of the JSON value. /// The object input to parse. /// The parsed result, or null if the parsing fails. /// True if the parsing results in a non-null value, false otherwise. bool TryDeserialize(object input, [NotNullWhen(true)] out T? value) where T : class; }