当一个字段为 object 类型时,System.Text.Json 自动设置 JsonElement 类型,而不是对应的类型,因此在很多情况下会出现奇怪的问题。 因此这里只要有两个地方加上代码,缓解这一情况。 第一步,实现转换器,当一个类型是 object 时,如果 json 是简单类型,则直接使[......] 继续阅读
当一个字段为 object 类型时,System.Text.Json 自动设置 JsonElement 类型,而不是对应的类型,因此在很多情况下会出现奇怪的问题。 因此这里只要有两个地方加上代码,缓解这一情况。 第一步,实现转换器,当一个类型是 object 时,如果 json 是简单类型,则直接使[......] 继续阅读
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[......] 继续阅读
Jq 是一个轻量级和灵活的命令行 JSON 处理器。 官网: https://jqlang.github.io/jq/ https://jqlang.github.io/jq/manual/ Jq 可以从 JSON 中解析数据以及将数据替换到字段表达式生成新的 Json。 例如一个 JSON: [......]继续阅读
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[......] 继续阅读
从 ServerlessWorkflow 中学习到一个有趣的 NewtonsoftJson 配置。 var newtonsoftJsonDefaultConfig = (JsonSerializerSettings settings) => {[......]继续阅读
From ServerlessWorkflow, I learned an interesting configuration for NewtonsoftJson. var newtonsoftJsonDefaultConfig = (JsonSerializerSetti[......]继续阅读
后面改进了对象池算法,使用结构体来存储,其性能变得非常强。 参考对象池算法:https://www.whuanle.cn/archives/20888 新版本 定义结构体存储每个字段: public struct JsonField { public string? Name {[......]继续阅读
后面改进了对象池算法,使用结构体来存储,其性能变得非常强。 参考对象池算法:https://www.whuanle.cn/archives/20888 New Version Define a structure to store each field: public struct JsonFiel[......]继续阅读
数据: 格式: { "a_tttttttttttt": 1001, "b_tttttttttttt": "邱平", "c_tttttttttttt": "Nancy Lee&quo[......]继续阅读
数据: 格式: { "a_tttttttttttt": 1001, "b_tttttttttttt": "邱平", "c_tttttttttttt": "Nancy Lee", "d_tttttttttttt": "buqdu", "e_tttttttt[......]继续阅读
// json => Dictionary static Dictionary<string, string> Read(string jsonData) { var reader = new Utf8Jso[......]继续阅读
// json => Dictionary static Dictionary<string, string> Read(string jsonData) { var reader = new Utf8Jso[......]继续阅读
Define the Converter: public class EnumStringConverter : JsonConverter<Enum> { public override bool CanConvert(Type objectType) { return obj[......]继续阅读
定义转换器: public class EnumStringConverter : JsonConverter<Enum> { public override bool CanConvert(Type objectType) { return object[......]继续阅读
Common JSON serialization configuration is as follows: // JSON serialization configuration private static readonly JsonSerializerOpti[......]继续阅读
常用的 Json 序列化配置如下: // json 序列化配置 private static readonly JsonSerializerOptions JsonSetting = new JsonSerializerOptions() {[......]继续阅读
在后端中,当有分布式需求时,我们常常使用 64位 的数字类型表示字段类型,但是前端并不支持超过 16 位长度的数值类型,所以后端长度较大的 long、ulong 数值传到后端,其准确度就已经丢失。 解决方法就是将 ulong、long 转为字符串,传递给后端。 public class Te[......]继续阅读
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[......] 继续阅读
public IConfigurationRoot Config { get; } = new ConfigurationBuilder() .SetBasePath(System.IO.Path.Combine(System.IO.Directory[......]继续阅读
public IConfigurationRoot Config { get; } = new ConfigurationBuilder() .SetBasePath(System.IO.Path.Combine(System.IO.Directory[......]继续阅读