피드를 만들거나 업데이트할 때 항목을 검증하려면 다음 JSON 스키마를 사용하세요. 스키마는 JSON 스키마 사양을 기반으로 합니다.
생성한 항목의 유효성을 검사하는 단위 테스트를 추가하면 피드 품질에 영향을 미치는 문제를 감지할 수 있습니다. 피드 개발 중에 이러한 스키마를 사용하여 일반적인 오류를 방지할 수도 있습니다.
미디어 작업 스키마 선택
VOD 스키마는 Movie, TVEpisode, TVSeries, TVSeason 항목을 검증합니다.
라이브 TV 스키마는 BroadcastEvent, BroadcastService, CableOrSatelliteService, Movie, Organization, SportsEvent, TelevisionChannel, TVEpisode, TVSeason, TVSeries 항목을 검증합니다.
음악 스키마는 MusicAlbum, MusicGroup, MusicPlaylist, MusicRecording 항목을 검증합니다.
제공된 스키마는 초안 7으로 작성되었으므로 선택한 구현이 이 버전을 지원해야 제대로 작동합니다.
유효성 검사의 예
다음 예에서는 스키마 파일 schema.json 및 jsonschema Python 모듈을 사용하여 feed.json 파일에 있는 모든 항목을 검증하는 방법을 보여줍니다. 항목은 데이터 피드 엔벨로프 문서에 지정된 대로 dataFeedElement 속성에 있습니다.
importjsonfromjsonschemaimportvalidate# Loading the schema filewithopen("schema.json","r")asfp:schema=json.load(fp)# Opening the feedwithopen("feed.json","r")asfp:feed=json.load(fp)# Validating each entity in the feedforentityinfeed["dataFeedElement"]:try:validate(schema=schema,instance=entity)print("Entity validated successfully")exceptExceptionase:# e may contain an explanation as to why the entity wasn't validprint("Failed to validate the entity")
[null,null,[],[[["JSON Schemas are provided to validate entities when creating or updating your data feed, ensuring data quality and consistency."],["Choose the appropriate Media Actions schema (VOD, Live TV, Music, or Radio) based on the type of entities in your feed."],["Select a validator implementation that supports JSON Schema draft 7 and integrate it into your workflow for automated validation."],["Refer to the specification on this site as the primary source of truth for entity requirements, as schemas may not include all features."],["Utilize the provided example code snippet to validate entities within your feed using the chosen schema and a compatible validator."]]],["To validate feed entities, use the provided JSON Schemas, based on the JSON Schema specification, for different media types: Video On Demand, Live TV, Music, and Radio. Add unit tests for validation to detect issues and avoid errors during feed development. Choose a validator implementation supporting draft 7, such as the `jsonschema` python module. Validate entities by loading the schema and feed, then iterating through entities in the `dataFeedElement` property and testing with the selected implementation, printing the results.\n"]]