2017-10-16 47 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" 
     ] 
    } 
    ] 
}