AI-generated Key Takeaways
-
JSON Schemas are provided to validate entities when creating or updating your feed, helping to detect issues and avoid errors during development.
-
Different JSON Schemas are available for validating specific media actions like Video On Demand, Live TV, Music, and Radio, each supporting different entity types.
-
You should select a validator that supports draft 7 of the JSON Schema specification to work with the provided schemas.
-
An example demonstrates how to validate entities in a feed using a schema file and a Python library.
To validate entities when you're creating or updating your feed, use the following JSON Schemas. The schemas are based on the JSON Schema specification . By adding a unit test to validate the entities you generate, you can detect issues that would impact the feed quality. You can also use these schemas during the development of your feed to avoid common errors.
Select a Media Actions schema
- Video On Demand Schema
validates
Movie,TVEpisode,TVSeriesandTVSeasonentities. - Live TV Schema
validates
BroadcastEvent,BroadcastService,CableOrSatelliteService,Movie,Organization,SportsEvent,TelevisionChannel,TVEpisode,TVSeasonandTVSeriesentities. - Music Schema
validates
MusicAlbum,MusicGroup,MusicPlaylistandMusicRecordingentities. - Radio Schema
validates
RadioBroadcastServiceentities.
Use the specification on this site as the source of truth, since these schemas may not have all the features implemented.
Choose a validator
You can find the list of validator implementations on json-schema.org .
The schemas provided are written in draft 7 , so the implementation you choose needs to support this version to work properly.
Example of validation
The following example show how to validate all entities present in a file feed.json
using the schema file schema.json
and the jsonschema
python module. The entities are in the
property dataFeedElement
as specified in the data feed envelope
documentation.
import
json
from
jsonschema
import
validate
# Loading the schema file
with
open
(
"schema.json"
,
"r"
)
as
fp
:
schema
=
json
.
load
(
fp
)
# Opening the feed
with
open
(
"feed.json"
,
"r"
)
as
fp
:
feed
=
json
.
load
(
fp
)
# Validating each entity in the feed
for
entity
in
feed
[
"dataFeedElement"
]
:
try
:
validate
(
schema
=
schema
,
instance
=
entity
)
print
(
"Entity validated successfully"
)
except
Exception
as
e
:
# e may contain an explanation as to why the entity wasn't valid
print
(
"Failed to validate the entity"
)

