using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
namespace Artemis.Core;
///
/// A static helper class that serializes and deserializes JSON with the Artemis Core JSON settings
///
public static class CoreJson
{
///
/// Serializes the specified object to a JSON string.
///
/// The object to serialize.
/// A JSON string representation of the object.
[DebuggerStepThrough]
public static string Serialize(object? value)
{
return JsonSerializer.Serialize(value, Constants.JsonConvertSettings);
}
///
/// Deserializes the JSON to the specified .NET type.
///
/// The type of the object to deserialize to.
/// The JSON to deserialize.
/// The deserialized object from the JSON string.
[DebuggerStepThrough]
[return: MaybeNull]
public static T Deserialize(string value)
{
return JsonSerializer.Deserialize(value, Constants.JsonConvertSettings);
}
///
/// Gets a copy of the JSON serializer options used by Artemis Core
///
/// A copy of the JSON serializer options used by Artemis Core
public static JsonSerializerOptions GetJsonSerializerOptions()
{
return new JsonSerializerOptions(Constants.JsonConvertSettings);
}
}