如何使用 MassTransit 更改属性的大小写

how to change the case of properties with MassTransit

如何将 属性 的格式从驼峰式更改为 PascalCase。

有没有标准化的格式化方式?一些中间件?我在文档中没有找到任何内容。

还有一个问题。为什么 masstransit 的 json 转换器将十进制转换为字符串?

示例: 我的 class:

public class Block
{
    public string Name { get; set; }
    public int Age { get; set; }
    public int AccountValue { get; set; }
}

当前生成的消息:

{
  "name": 3,
  "age": 34,
  "accountValue": "3430.64"
}

预期消息:

{
  "Name": 3,
  "Age": 34,
  "AccountValue": 3430.64
}

感谢任何帮助

要更改 JSON 序列化程序设置,您可以调用:

cfg.ConfigureJsonSerializer(x => ...)

配置总线时。

MassTransit 将 decimal 转换为字符串,因为 decimal 类型比 JSON float 类型更精确。如果您希望它不是字符串,请使用双精度而不是小数。

对于相关评论, 为什么小数不应作为 JSON 浮点数传递。