2

How to change the formatting of a property from camelCase to PascalCase.

Is there any standardized way to format? some middleware? I didn't find anything in the documentation.

And one more question. Why does masstransit's json converter convert decimal to string?

Examplo: My class:

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

currently generated message:

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

expected message:

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

I appreciate any help

kelvin sand
  • 413
  • 4
  • 13

1 Answers1

2

To change the JSON serializer setting, you can call:

cfg.ConfigureJsonSerializer(x => ...)

When configuring the bus.

MassTransit converts decimal to a string because decimal types are more precise than JSON float types. If you want it to not be a string, use a double instead of a decimal.

For relevant comments, look at this answer as to why decimals should not be passed as JSON floats.

Chris Patterson
  • 28,659
  • 3
  • 47
  • 59