Hi team, I am working on creating new consumer con...
# pactflow
s
Hi team, I am working on creating new consumer contract tests and for that I need properties of the consumer pact json to follow a custom order, currently it seems the properties follow alphabetical order in json pact in pactflow. Is there any way to change the order of properties of consumer pact in pactflow? Thanks in advance
example like this
Copy code
"example": 
          {
            "firstKey": "value1",
            "secondKey": "value2",
            "thirdKey": "value3"
          }
how to change order of keys in above like this in pactflow
Copy code
exampleNew": 
          {
	        "thirdKey": "value3"
            "secondKey": "value2",
            "firstKey": "value1",
          }
m
The order is not controllable. Why do you need it to be ordered?
s
hey, really sorry for the delay but the reason is that one of the properties has a type using JsonPolymorphic with TypeDiscriminatorPropertyName and .NET makes it obligatory for these metadata properties to be presented first in the json response or else we will get an error and when we arrange it correctly it passes locally, but pactflow overrides and rearranges the properties in alphabetical manner and fails
m
wait, .NET mandates that the discriminator property be first in the properties??
s
yes, and this is the type of error
Copy code
// JsonException: The metadata property is either not supported by the type or is not the first property in the deserialized JSON object.
m
This is such madness, God I hate .NET 🤣 @rholshausen any ideas (aside from not using .NET ;) )
r
No, there is no way to guarantee the order. It depends on the underlying JSON library, which orders the keys. Ordering the keys means the generated JSON is always constant.
s
okay , thanks everyone for this info
m
Could you post process the json before uploading Santosh? Not sure if our verifier will reorder them on loading
s
yeah okay I can try this