"data": {
"type": "systems",
"attributes": {
"display_name": "Meals",
"is_generic": false,
"interaction_object": "BlahBlah"
},
"relationships": {
"account": {
"data": {
"type": "accounts",
"id": 204
}
},
"venue": {
"data": {
"type": "venues",
"id": 187
}
}
}
}
}
请帮忙。:) 根据属性值调节有问题。我需要根据简单的条件验证 JSON:
- if
attributes.is_generic === false
> 帐户和场所属性应存在于关系属性中 - 如果
attributes.is_generic === true
> 只有场地应该在场
预先感谢。
准备好基本架构:
type: 'object',
properties: {
data: {
properties: {
type: { type: 'string' },
attributes: {
properties: {
display_name: { type: 'string' },
is_generic: { type: 'boolean' },
interaction_object: { type: 'string' },
},
required: ['display_name', 'is_generic', 'interaction_object']
},
relationships: {
properties: {
account: {
properties: {
data: {
properties: {
type: { type: 'string' },
id: { type: 'number' },
},
required: [ 'type', 'id'],
}
},
required: ['data'],
},
venue: {
properties: {
data: {
properties: {
type: { type: 'string' },
id: { type: 'number' },
},
required: [ 'type', 'id'],
}
},
required: ['data'],
},
},
required: ['venue', 'account']
}
},
required: ['attributes', 'relationships']
}
},
required: ['data'],
additionalProperties: false,
谢谢你的帮助