موجودیت ها را با طرحواره های JSON اعتبار سنجی کنید
با مجموعهها، منظم بمانید
ذخیره و دستهبندی محتوا براساس اولویتهای شما.
برای اعتبارسنجی نهادها هنگام ایجاد یا بهروزرسانی فید خود، از طرحوارههای JSON زیر استفاده کنید. طرحواره ها بر اساس مشخصات طرحواره JSON هستند. با افزودن یک تست واحد برای اعتبارسنجی موجودیت هایی که تولید می کنید، می توانید مشکلاتی را که بر کیفیت خوراک تأثیر می گذارد شناسایی کنید. همچنین می توانید از این طرحواره ها در طول توسعه فید خود استفاده کنید تا از خطاهای رایج جلوگیری کنید.
طرحی از اقدامات رسانه ای را انتخاب کنید
طرحواره ویدیوی درخواستی موجودیت های Movie ، TVEpisode ، TVSeries و TVSeason را تأیید می کند.
طرحواره تلویزیون زنده ، موجودیتهای BroadcastEvent ، BroadcastService ، CableOrSatelliteService ، Movie ، Organization ، SportsEvent ، TelevisionChannel ، TVEpisode ، TVSeason و TVSeries را تأیید میکند.
Music Schema موجودیتهای MusicAlbum ، MusicGroup ، MusicPlaylist و MusicRecording را تأیید میکند.
طرحواره رادیویی نهادهای RadioBroadcastService را تأیید می کند.
از مشخصات موجود در این سایت به عنوان منبع حقیقت استفاده کنید، زیرا ممکن است این طرحواره ها همه ویژگی های اجرا شده را نداشته باشند.
طرحواره های ارائه شده در پیش نویس 7 نوشته شده اند، بنابراین پیاده سازی که انتخاب می کنید باید از این نسخه پشتیبانی کند تا به درستی کار کند.
نمونه ای از اعتبار سنجی
مثال زیر نشان می دهد که چگونه می توان تمام موجودیت های موجود در یک فایل feed.json را با استفاده از فایل طرحواره schema.json و ماژول پایتون jsonschema اعتبارسنجی کرد. موجودیت ها همانطور که در اسناد پاکت خوراک داده مشخص شده است در 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")
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],[],[[["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"]]