Reputation: 11
{
"data": {
"uCPE PostStaging Completed": false,
"Order Submitted": true,
"uCPE PreStaging Completed": false,
"Poststaging device deploy success": true,
"uCPE Activated": false
},
"status": "SUCCESS"
}
Above mentioned is my Response Body. This keeps changing when a different input is provided. But I want the response only in the following Order. The KEY should be in the below order, however the values for each key will be changing.
“Order Submitted”:”true”,
"Poststaging device deploy success" : “true”,
"uCPE PreStaging Completed": “ true”,
“uCPE PostStaging Completed" : “false”,
“Order Completed”:”false”,
"uCPE Activated":"false"
Upvotes: 0
Views: 118
Reputation: 2655
As @Alan Sereb and @Roman Vottner suggested, @JsonPropertyOrder
is best option if you are using your pojo
class as response.
However, If you are passing Collection
classes object directly to your parser and want to maintain the order then you need to use LinkedXXX
or ArrayList
for list interface. In your case as your are using Map<List>
, you should use LinkedHashMap
implementation.
This has very good explanations of Collection
framework.
Upvotes: 1
Reputation: 2571
If you are using Jackson, look into @JsonPropertyOrder
.
In your case it would be something like this:
@JsonPropertyOrder({
"orderSubmitted",
"deploySuccess",
"preStagingCompleted",
"postStaingCompleted",
"orderCompleted",
"ucpeActivated"
})
Upvotes: 1