mirror of
https://github.com/nsnail/ns-ext.git
synced 2025-04-19 00:02:50 +08:00

* <chore> * 1.0.7 * <adjust> * <chore> * <chore> * <refactor> * <doc> * <doc> * <feat> + Unicode,UnicodeDe * <revert> * <fix> * bugfix * <feat> 从资源文件读取Description * <feat> 从资源文件读取Description-可继承 * <fix> 将一个对象序列化成json文本 * <chore> * 调整一下日志格式 * feat: * 泛型特性本地化资源描述 * 添加测试项目 * <chore> * feat: enum、string * feat: long 类型增加rand方法 * feat: ToInvString * fix: ToInvString * fix: ToInvString * fix: ParameterFormat bug * [BLD] [SKIP CI]
30 lines
771 B
C#
30 lines
771 B
C#
using System.Text.Json;
|
|
|
|
namespace NSExt.Extensions;
|
|
|
|
/// <summary>
|
|
/// ObjectExtensions
|
|
/// </summary>
|
|
public static class ObjectExtensions
|
|
{
|
|
/// <summary>
|
|
/// 将一个对象序列化成json文本
|
|
/// </summary>
|
|
/// <param name="me">me</param>
|
|
/// <returns>json文本</returns>
|
|
public static string Json(this object me)
|
|
{
|
|
return JsonSerializer.Serialize(me);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 将一个对象序列化成json文本
|
|
/// </summary>
|
|
/// <param name="me">me</param>
|
|
/// <param name="options">序列化选项</param>
|
|
/// <returns>json文本</returns>
|
|
public static string Json(this object me, JsonSerializerOptions options)
|
|
{
|
|
return JsonSerializer.Serialize(me, options);
|
|
}
|
|
} |