java在json模式中使用正则表达式来验证字符串是否没有空格?
我已经为你写了一个模式。json文件验证。我需要验证字符串是否没有空格。我发现我可以使用“pattern”和regex表达式,但它不起作用。 模式验证不起作用
my json file
// @Validation(SchemaFile=config-schema.json)
{
"StoresList": [
{
"StoreId": "Store1",
"EntityIdList": [
"item1",
"item_2",
"item_3"
]
},
{
"StoreId": "Store2",
"EntityIdList": [
"item1",
"item_2",
"item_3"
]
}
]
}
schema file
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"StoresList": {
"type": "array",
"items": {
"type": "object",
"properties": {
"StoreId": {
"type": "string"
},
"EntityIdList": {
"type": "array",
"items": {
"type": "string"
"pattern": "^\\s"
}
}
},
"required": [
"StoreId",
"EntityIdList"
]
}
}
},
"required": [
"StoresList"
]
}
共 (0) 个答案