src/YL.Utils/Json/Json.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using YL.Utils.Check;
using YL.Utils.Env;
using YL.Utils.Extensions;

namespace YL.Utils.Json
{
    public static class Json
    {
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static string ToJsonL(this object obj)
        {
            var config = GlobalCore.GetRequiredService<JsonConfig>();
            CheckNull.ArgumentIsNullException(config, "请添加app.UseGlobalCore();services.AddJson();");
            switch (config.JsonType)
            {
                case JsonType.MessagePack:
                    return obj.MpToJson();

                case JsonType.ProtobufNet:
                    throw new Exception("未实现");

                case JsonType.SimdJsonSharp:
                    throw new Exception("未实现");

                case JsonType.SpanJson:
                    throw new Exception("未实现");

                case JsonType.SwifterJson:
                    if (config.SwifterJsonConfig.DateTimeFormat.IsEmpty())
                    {
                        return obj.SwifterToJson();
                    }
                    else
                    {
                        return obj.SwifterToJson(config.SwifterJsonConfig.DateTimeFormat, config.SwifterJsonConfig.JsonFormatterOptions);
                    }

                case JsonType.Utf8Json:
                    return obj.Utf8JsonToJson();

                case JsonType.Jil:
                    return obj.JilToJson();

                case JsonType.ServiceStackText:
                    throw new Exception("未实现");

                case JsonType.Newtonsoft:

                    return obj.ToJson(config.Newtonsoft.DateTimeFormat);

                case JsonType.TextJson:

                    return obj.ToTextJson();

                default:
后面还有 46 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。