2025-05-23 11:12:15 +02:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BS.Shared.Core
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class JsonUtils
|
|
|
|
|
|
{
|
|
|
|
|
|
public static string ToSimpleJson(string key, object value)
|
|
|
|
|
|
{
|
|
|
|
|
|
var dict = new Dictionary<string, object>()
|
|
|
|
|
|
{
|
|
|
|
|
|
{key, value }
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return JsonConvert.SerializeObject(dict);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-23 10:44:27 +02:00
|
|
|
|
public static string ConvertToJson(Dictionary<string, object> dict)
|
2025-05-23 11:12:15 +02:00
|
|
|
|
{
|
|
|
|
|
|
var json = JsonConvert.SerializeObject(dict);
|
|
|
|
|
|
|
|
|
|
|
|
return json;
|
|
|
|
|
|
}
|
2025-09-23 10:44:27 +02:00
|
|
|
|
|
|
|
|
|
|
public static string ConvertToJson(dynamic payload, Formatting formatting = Formatting.None)
|
|
|
|
|
|
{
|
|
|
|
|
|
var json = JsonConvert.SerializeObject((object)payload, formatting);
|
|
|
|
|
|
|
|
|
|
|
|
return json;
|
|
|
|
|
|
}
|
2025-05-23 11:12:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|