当一个字段为 object 类型时,System.Text.Json 自动设置 JsonElement 类型,而不是对应的类型,因此在很多情况下会出现奇怪的问题。 因此这里只要有两个地方加上代码,缓解这一情况。 第一步,实现转换器,当一个类型是 object 时,如果 json 是简单类型,则直接使[......] 继续阅读

2024年7月10日 0条评论 2875点热度 0人点赞 痴者工良 阅读全文

When a field is of object type, System.Text.Json automatically sets it to the JsonElement type instead of the corresponding type, leading to strange i[......] 继续阅读

2024年7月10日 0条评论 106点热度 0人点赞 痴者工良 阅读全文

Jq 是一个轻量级和灵活的命令行 JSON 处理器。 官网: https://jqlang.github.io/jq/ https://jqlang.github.io/jq/manual/ Jq 可以从 JSON 中解析数据以及将数据替换到字段表达式生成新的 Json。 例如一个 JSON: [......]继续阅读

2023年6月6日 2条评论 2633点热度 1人点赞 痴者工良 阅读全文

Jq is a lightweight and flexible command-line JSON processor. Official website: https://jqlang.github.io/jq/ https://jqlang.github.io/jq/manual/ Jq ca[......] 继续阅读

2023年6月6日 2条评论 86点热度 1人点赞 痴者工良 阅读全文

从 ServerlessWorkflow 中学习到一个有趣的 NewtonsoftJson 配置。 var newtonsoftJsonDefaultConfig = (JsonSerializerSettings settings) => {[......]继续阅读

2022年11月19日 0条评论 2183点热度 1人点赞 痴者工良 阅读全文

From ServerlessWorkflow, I learned an interesting configuration for NewtonsoftJson. var newtonsoftJsonDefaultConfig = (JsonSerializerSetti[......]继续阅读

2022年11月19日 0条评论 2187点热度 1人点赞 痴者工良 阅读全文

后面改进了对象池算法,使用结构体来存储,其性能变得非常强。 参考对象池算法:https://www.whuanle.cn/archives/20888 新版本 定义结构体存储每个字段: public struct JsonField { public string? Name {[......]继续阅读

2022年10月24日 0条评论 2695点热度 1人点赞 痴者工良 阅读全文

后面改进了对象池算法,使用结构体来存储,其性能变得非常强。 参考对象池算法:https://www.whuanle.cn/archives/20888 New Version Define a structure to store each field: public struct JsonFiel[......]继续阅读

2022年10月24日 0条评论 104点热度 1人点赞 痴者工良 阅读全文

数据: 格式: { "a_tttttttttttt": 1001, "b_tttttttttttt": "邱平", "c_tttttttttttt": "Nancy Lee&quo[......]继续阅读

2022年10月20日 0条评论 2020点热度 0人点赞 痴者工良 阅读全文

数据: 格式: { "a_tttttttttttt": 1001, "b_tttttttttttt": "邱平", "c_tttttttttttt": "Nancy Lee", "d_tttttttttttt": "buqdu", "e_tttttttt[......]继续阅读

2022年10月20日 0条评论 2004点热度 0人点赞 痴者工良 阅读全文

// json => Dictionary static Dictionary<string, string> Read(string jsonData) { var reader = new Utf8Jso[......]继续阅读

2022年10月10日 0条评论 94点热度 0人点赞 痴者工良 阅读全文

// json => Dictionary static Dictionary<string, string> Read(string jsonData) { var reader = new Utf8Jso[......]继续阅读

2022年10月10日 0条评论 2134点热度 0人点赞 痴者工良 阅读全文

Define the Converter: public class EnumStringConverter : JsonConverter<Enum> { public override bool CanConvert(Type objectType) { return obj[......]继续阅读

2022年7月18日 0条评论 3421点热度 4人点赞 痴者工良 阅读全文

定义转换器: public class EnumStringConverter : JsonConverter<Enum> { public override bool CanConvert(Type objectType) { return object[......]继续阅读

2022年7月18日 0条评论 3397点热度 4人点赞 痴者工良 阅读全文

Common JSON serialization configuration is as follows: // JSON serialization configuration private static readonly JsonSerializerOpti[......]继续阅读

2021年8月12日 0条评论 4991点热度 3人点赞 痴者工良 阅读全文

常用的 Json 序列化配置如下: // json 序列化配置 private static readonly JsonSerializerOptions JsonSetting = new JsonSerializerOptions() {[......]继续阅读

2021年8月12日 0条评论 5005点热度 3人点赞 痴者工良 阅读全文

在后端中,当有分布式需求时,我们常常使用 64位 的数字类型表示字段类型,但是前端并不支持超过 16 位长度的数值类型,所以后端长度较大的 long、ulong 数值传到后端,其准确度就已经丢失。 解决方法就是将 ulong、long 转为字符串,传递给后端。 public class Te[......]继续阅读

2021年7月12日 1条评论 4494点热度 0人点赞 痴者工良 阅读全文

In the backend, when there are distributed demands, we often use 64-bit numeric types to represent field types. However, the frontend does not support[......] 继续阅读

2021年7月12日 1条评论 94点热度 0人点赞 痴者工良 阅读全文

public IConfigurationRoot Config { get; } = new ConfigurationBuilder() .SetBasePath(System.IO.Path.Combine(System.IO.Directory[......]继续阅读

2020年4月16日 0条评论 2948点热度 0人点赞 痴者工良 阅读全文

public IConfigurationRoot Config { get; } = new ConfigurationBuilder() .SetBasePath(System.IO.Path.Combine(System.IO.Directory[......]继续阅读

2020年4月16日 0条评论 88点热度 0人点赞 痴者工良 阅读全文
12