System.Text.Json – Control the order that properties get serialized

You can use the JsonPropertyOrder attribute to control the order that properties get serialized. You specify the order as an integer, and it serializes the properties in ascending order. Here’s an example: Note: Properties have a default order value of 0. Now serialize a Programmer object: This generates the following JSON with the properties serialized … Read more