{
"data": {
"uCPE PostStaging Completed": false,
"Order Submitted": true,
"uCPE PreStaging Completed": false,
"Poststaging device deploy success": true,
"uCPE Activated": false
},
"status": "SUCCESS"
}
以上是我的回应机构。当提供不同的输入时,它会不断变化。但是我只希望按照以下顺序进行响应。密钥应按以下顺序排列,但是每个密钥的值都会改变。
“Order Submitted”:”true”,
"Poststaging device deploy success" : “true”,
"uCPE PreStaging Completed": “ true”,
“uCPE PostStaging Completed" : “false”,
“Order Completed”:”false”,
"uCPE Activated":"false"
最佳答案
如果您正在使用Jackson,请查看@JsonPropertyOrder
。
在您的情况下,将是这样的:
@JsonPropertyOrder({
"orderSubmitted",
"deploySuccess",
"preStagingCompleted",
"postStaingCompleted",
"orderCompleted",
"ucpeActivated"
})
关于java - 如何以所需的方式对REST API响应进行排序?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57717733/