CSharp · Console
using System;
using System.Text.Json;
namespace ConsoleApp
{
public interface INotification
{
Severity Severity { get; set; }
string Message { get; set; }
public string SeverityName => Severity.ToString().ToLower();
}
public enum Severity
{
Info,
Warning,
Error,
}
public class Notification : INotification
{
public Severity Severity { get; set; }
public string Message { get; set; }
}
class Program
{
static void Main(string[] args)
{
var notification = new Notification
{
Message = "Message",
Severity = Severity.Info
};
var jsonText = JsonSerializer.Serialize(notification);
Console.WriteLine(jsonText);
}
}
}