2017-10-16 56 views
0
{ 
    "email": "[email protected]", 
    "phone": "9033931947", 
    "country_code": "91", 
    "firstname":"Rakesh", 
    "surname" :"A R"    
} 

我想要么firstnamesurname是在我的请求(等中的一个:“名字”或“姓”)来验证的DataPower以下JSON架构我想用模式文件

例如:

{ 
    "email": "[email protected]", 
    "phone": "9033931947", 
    "country_code": "91", 
    "firstname":"Rakesh"            
} 

{ 
    "email": "[email protected]", 
    "phone": "9033931947", 
    "country_code": "91", 
    "surname":"A R"         
} 

能否请你帮我JSON血清胆碱酯酶马我的要求?

回答

0

例如这样的事情。这有点复杂,但如果你想确切地使用其他姓氏或fisrtName而不是在一起,而不是缺少它们,这就是你所需要的。

{ 
    "$schema": "http://json-schema.org/draft-04/schema#", 
    "definitions": { 
    "email": { 
     "type": "string" 
    }, 
    "phone": { 
     "type": "string" 
    }, 
    "country_code": { 
     "type": "string" 
    } 
    }, 
    "type": "object", 
    "oneOf": [ 
    { 
     "properties": { 
     "email": { 
      "$ref": "#/definitions/email" 
     }, 
     "phone": { 
      "$ref": "#/definitions/phone" 
     }, 
     "county_code": { 
      "$ref": "#/definitions/country_code" 
     }, 
     "firstname": { 
      "type": "string" 
     } 
     }, 
     "required": [ 
     "email", 
     "phone", 
     "country_code", 
     "firstname" 
     ] 
    }, 
    { 
     "properties": { 
     "email": { 
      "$ref": "#/definitions/email" 
     }, 
     "phone": { 
      "$ref": "#/definitions/phone" 
     }, 
     "county_code": { 
      "$ref": "#/definitions/country_code" 
     }, 
     "surname": { 
      "type": "string" 
     } 
     }, 
     "required": [ 
     "email", 
     "phone", 
     "country_code", 
     "surname" 
     ] 
    } 
    ] 
}