Skip to content

添加json设置参数, 适配Newtonsoft Json#247

Merged
Alex-Rachel merged 1 commit intoAlex-Rachel:mainfrom
LSDust:main
Apr 16, 2026
Merged

添加json设置参数, 适配Newtonsoft Json#247
Alex-Rachel merged 1 commit intoAlex-Rachel:mainfrom
LSDust:main

Conversation

@LSDust
Copy link
Copy Markdown
Contributor

@LSDust LSDust commented Apr 2, 2026

添加带默认值的参数, 兼容旧api

@Alex-Rachel
Copy link
Copy Markdown
Owner

可以提供个示例?这个自定义的setting需要什么情况下用?

@LSDust
Copy link
Copy Markdown
Contributor Author

LSDust commented Apr 15, 2026

我自己是为了反序列化带"$type"的json,示例大致是

var settings = new JsonSerializerSettings
{
    SerializationBinder = new KnownTypesBinder
    {
        KnownTypes = new List<System.Type>
        {
            typeof(class1),
            typeof(class2)
        }
    }
};
var data = Utility.Json.ToObject<T>(jsonString,settings)

@Alex-Rachel Alex-Rachel merged commit 5b8d232 into Alex-Rachel:main Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants