JSON is in fact unordered by design. You should not attempt to force a specific ordering, and any recipient of JSON data who expects specific ordering has a badly designed process. (eg. they have implemented their own brain-dead parser rather than using a standard library, of which there are many for all common programming languages)
Refer to RFC8259 (or 7159 or 4267) that states in the introduction:
An object is an unordered collection of zero or more name/value
pairs, where a name is a string and a value is a string, number,
boolean, null, object, or array.