【发布时间】:2018-11-06 14:28:35
【问题描述】:
我知道 json 架构对象中列出的字段没有定义的顺序,因为它们不是数组,但我正在寻找一种能够在我的应用程序 UI 中以正确顺序显示它们的方法。
到目前为止,我发现的解决方法包括使用不同的serializer,甚至将数字硬编码到字段名称中。
我想提出一些适用于我当前设置的东西。 Hibernate、Spring Boot 和 react-app 前端。 给定这个 GET 请求:
/profile/personEntities
带有标题:接受:application/schema+json
我会收到这个:
{
"title": "Person entity",
"properties": {
"birthday": {
"title": "Birthday",
"readOnly": false,
"type": "string",
"format": "date-time"
},
"lastName": {
"title": "Last name",
"readOnly": false,
"type": "string"
},
"address": {
"title": "Address",
"readOnly": false,
"type": "string",
"format": "uri"
},
"firstName": {
"title": "First name",
"readOnly": false,
"type": "string"
},
"email": {
"title": "Email",
"readOnly": false,
"type": "string"
},
"cellPhone": {
"title": "Cell phone",
"readOnly": false,
"type": "string"
}
},
"requiredProperties": [
"firstName",
"lastName"
],
"definitions": {},
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#"
}
我尝试将@JsonProperty(index=2) 添加到该字段,但没有任何变化。
非常感谢您提供的任何提示。
【问题讨论】:
标签: mysql hibernate spring-boot jsonschema