JSON 스키마(JSON Schema)는 [[JSON]] 데이터가 따라야 할 구조와 값의 조건을 기술하는 방법이다. 파일이 JSON 문법에 맞는지와, 작업에 필요한 필드가 갖춰졌는지를 구분해 검사한다. ([JSON Schema의 객체 안내](https://json-schema.org/understanding-json-schema/reference/object)) - 예컨대 도서 목록의 title은 문자열, year는 정수라는 조건을 정할 수 있다. 값이 들어올 때 [[데이터 검증]] 도구가 그 조건과 비교한다. ([객체 속성의 조건](https://json-schema.org/understanding-json-schema/reference/object)) - `properties`에 필드를 적는 것만으로 필수 입력이 되지 않는다. 반드시 필요한 필드는 `required`에도 지정한다. ([필수 속성](https://json-schema.org/understanding-json-schema/reference/object)) - 정의하지 않은 필드를 금지하려면 `additionalProperties` 같은 조건을 명시한다. 허용할 추가 정보를 결정하지 않은 채 스키마를 닫으면 새로운 필드를 받지 못할 수 있다. ([추가 속성](https://json-schema.org/understanding-json-schema/reference/object)) ## 기타 등등 - 필드가 없는 상태와 값이 null인 상태는 다르다. 문자열 필드에 null을 넣으면 문자열 조건을 만족하지 않는다. [출처](https://json-schema.org/understanding-json-schema/reference/object) - `patternProperties`의 정규식은 자동으로 문자열 전체에 고정되지 않는다. 이름 전체를 검사하려면 시작과 끝의 경계를 고려한다. [출처](https://json-schema.org/understanding-json-schema/reference/object) #데이터 #JSON #표준