2014-07-14 1 views
1

JsonSchema에서 여러 유형을 설정하려면 어떻게해야합니까? 아래 예제의 설명 필드는 JsonSchemaType.String 또는 JsonSchemaType.null이되고 싶습니다.Json.Net의 JsonSchema 필드에 여러 유형을 설정하는 방법은 무엇입니까?

{PropertyNames.Id, new JsonSchema { Type = JsonSchemaType.Integer, Required = true }}, 
     {PropertyNames.Description, new JsonSchema { Type = JsonSchemaType.String, Required = true }} 

또한 정수형 및 부동 소수점으로 구성된 배열이 있습니다.

유효성을 확인했지만 유효하지 않으므로 유효성 검사가 실패합니다. 나는 형처럼 = JsonSchemaType.Integer "또는"JsonSchemaType.Float

+1

를 사용하여 수행 할 수 있습니다. * 제목에 묻는 질문을 넣으십시오. * –

답변

2

을 뭔가를 할 수 그것은 당신의 질문의 제목에 Google 검색을 넣지 마십시오 간단한 | 운영자

result[PropertyNames.Metrics] = new JsonSchema 
{ 
    Type = JsonSchemaType.Array, 
    Required = true, 
    Items = new List<JsonSchema> 
    { 
     new JsonSchema() 
     { 
      Type = JsonSchemaType.Integer | JsonSchemaType.Null 
     } 
    } 
};