当前位置: 首页 > news >正文

wordpress多版seo网站有优化培训吗

wordpress多版,seo网站有优化培训吗,web怎么读,网站流量怎么做乡1万在 JSON 中,anyOf 语句通常用于 JSON Schema(JSON 模式)中,来定义多个可能的模式,表示数据可以匹配多个子模式中的任意一个。这种功能常用于验证 JSON 数据是否符合某一组可能的条件之一。 1、问题背景 问题&#xff…

在 JSON 中,anyOf 语句通常用于 JSON Schema(JSON 模式)中,来定义多个可能的模式,表示数据可以匹配多个子模式中的任意一个。这种功能常用于验证 JSON 数据是否符合某一组可能的条件之一。

在这里插入图片描述

1、问题背景

问题:如何编写 JSON 使其符合给定的 JSON Schema 结构?在 JSON Schema 中,存在一个“anyOf”关键字,要求至少满足一个条件。

2、解决方案

为了符合给定的 JSON Schema 结构,需要对 JSON 进行以下修改:

  • 使用anyOf关键字可以确保至少满足一个条件。
special_needs = [{"main": ["learning"],"sub": ["ADD/ADHD"]},{"main": ["behavioral"]}
]
  • mainsub属性需要放在同一个对象中。
special_needs = [{"category_0": {"main": ["learning"],"sub": ["ADD/ADHD", "dyslexia", "general learning disability", "language disorder", "intellectual giftedness", "other"]}},{"category_1": {"main": ["mental"],"sub": ["down's syndrome", "asperger's syndrome", "autism", "other"]}},{"category_2": {"main": ["behavioral"]}},{"category_3": {"main": ["medical"],"sub": ["diabetes", "allergies", "eating disorders", "chronic illness", "other"]}},{"category_4": {"main": ["physical"],"sub": ["blind", "deaf", "cerebral palsy", "other"]}}
]
  • 将JSON中的dict改为[],这样才符合anyOf中的要求。
special_needs = [{"category_0": {"main": ["learning"],"sub": ["ADD/ADHD", "dyslexia", "general learning disability", "language disorder", "intellectual giftedness", "other"]}},{"category_1": {"main": ["mental"],"sub": ["down's syndrome", "asperger's syndrome", "autism", "other"]}},{"category_2": {"main": ["behavioral"]}},{"category_3": {"main": ["medical"],"sub": ["diabetes", "allergies", "eating disorders", "chronic illness", "other"]}},{"category_4": {"main": ["physical"],"sub": ["blind", "deaf", "cerebral palsy", "other"]}}
]
  • anyOf仅适用于数组类型,因此special_needs应该是一个数组。
special_needs = [{"category_0": {"main": ["learning"],"sub": ["ADD/ADHD", "dyslexia", "general learning disability", "language disorder", "intellectual giftedness", "other"]}},{"category_1": {"main": ["mental"],"sub": ["down's syndrome", "asperger's syndrome", "autism", "other"]}},{"category_2": {"main": ["behavioral"]}},{"category_3": {"main": ["medical"],"sub": ["diabetes", "allergies", "eating disorders", "chronic illness", "other"]}},{"category_4": {"main": ["physical"],"sub": ["blind", "deaf", "cerebral palsy", "other"]}}
]

代码示例:

import json# 创建一个包含“anyOf”关键字的 JSON Schema
schema = {"$schema": "http://json-schema.org/draft-04/schema#","type": "object","properties": {"special_needs": {"type": "array","items": {"anyOf": [{"properties": {"category_0": {"type": "object","properties": {"main": {"type": "array","items": {"type": "string","enum": ["learning"]}},"sub": {"type": "array","items": {"type": "string","enum": ["ADD/ADHD", "dyslexia", "general learning disability", "language disorder", "intellectual giftedness", "other"]}}}}}},{"properties": {"category_1": {"type": "object","properties": {"main": {"type": "array","items": {"type": "string","enum": ["mental"]}},"sub": {"type": "array","items": {"type": "string","enum": ["down's syndrome", "asperger's syndrome", "autism", "other"]}}}}}},{"properties": {"category_2": {"type": "object","properties": {"main": {"type": "array","items": {"type": "string","enum": ["behavioral"]}}}}}},{"properties": {"category_3": {"type": "object","properties": {"main": {"type": "array","items": {"type": "string","enum": ["medical"]}},"sub": {"type": "array","items": {"type": "string","enum": ["diabetes", "allergies", "eating disorders", "chronic illness", "other"]}}}}}},{"properties": {"category_4": {"type": "object","properties": {"main": {"type": "array","items": {"type": "string","enum": ["physical"]}},"sub": {"type": "array","items": {"type": "string","enum": ["blind", "deaf", "cerebral palsy", "other"]}}}}}}]}}}
}# 创建一个符合 JSON Schema 的 JSON 数据
data = {"special_needs": [{"category_0": {"main": ["learning"],"sub": ["ADD/ADHD"]}},{"category_1": {"main": ["mental"],"sub": ["down's syndrome"]}}]
}# 验证 JSON 数据是否符合 JSON Schema
validator = jsonschema.Draft4Validator(schema)
if validator.is_valid(data):print("JSON data is valid")
else:print("JSON data is invalid")# 输出 JSON 数据
print(json.dumps(data, indent=4))

运行代码输出如下:

JSON data is valid
{"special_needs": [{"category_0": {"main": ["learning"],"sub": ["ADD/ADHD"]}},{"category_1": {"main": ["mental"],"sub": ["down's syndrome"]}}]
}

总结

  • anyOf 允许定义多个可能的模式,数据只需符合其中之一即可。
  • 它在 JSON Schema 中用于灵活的验证场景,尤其当字段可以有多种可能的结构时。

这种模式非常适合需要灵活数据验证的场景,比如 API 请求的验证、表单数据的校验等。


文章转载自:
http://sailor.wjrq.cn
http://luteolysin.wjrq.cn
http://frittata.wjrq.cn
http://sexisyllabic.wjrq.cn
http://triffidian.wjrq.cn
http://acid.wjrq.cn
http://lymphatolysis.wjrq.cn
http://vestryman.wjrq.cn
http://goodwife.wjrq.cn
http://hereinto.wjrq.cn
http://neocomian.wjrq.cn
http://uplight.wjrq.cn
http://valentine.wjrq.cn
http://snurfing.wjrq.cn
http://diffuser.wjrq.cn
http://attractant.wjrq.cn
http://limby.wjrq.cn
http://knottily.wjrq.cn
http://transform.wjrq.cn
http://aldis.wjrq.cn
http://repechage.wjrq.cn
http://enforcement.wjrq.cn
http://generotype.wjrq.cn
http://urinous.wjrq.cn
http://deoxidise.wjrq.cn
http://wordbook.wjrq.cn
http://barograph.wjrq.cn
http://scrieve.wjrq.cn
http://gastroenteritis.wjrq.cn
http://geepound.wjrq.cn
http://gotha.wjrq.cn
http://undamped.wjrq.cn
http://beamy.wjrq.cn
http://chervil.wjrq.cn
http://polypody.wjrq.cn
http://dragline.wjrq.cn
http://whity.wjrq.cn
http://otiose.wjrq.cn
http://divvers.wjrq.cn
http://sonuvabitch.wjrq.cn
http://wiring.wjrq.cn
http://coccus.wjrq.cn
http://morbifical.wjrq.cn
http://gastropod.wjrq.cn
http://ems.wjrq.cn
http://diol.wjrq.cn
http://materialize.wjrq.cn
http://refrangibility.wjrq.cn
http://deradicalize.wjrq.cn
http://protonema.wjrq.cn
http://radiobiology.wjrq.cn
http://ecumenic.wjrq.cn
http://patronite.wjrq.cn
http://welland.wjrq.cn
http://aerographer.wjrq.cn
http://vulcanism.wjrq.cn
http://limbed.wjrq.cn
http://iconometer.wjrq.cn
http://defocus.wjrq.cn
http://schadenfreude.wjrq.cn
http://cupferron.wjrq.cn
http://colocynth.wjrq.cn
http://brazilin.wjrq.cn
http://underdevelop.wjrq.cn
http://microoperation.wjrq.cn
http://corny.wjrq.cn
http://intercommunicate.wjrq.cn
http://gastrointestinal.wjrq.cn
http://neighborite.wjrq.cn
http://possession.wjrq.cn
http://captor.wjrq.cn
http://sulfurate.wjrq.cn
http://epithelioid.wjrq.cn
http://arithograph.wjrq.cn
http://compulsively.wjrq.cn
http://bust.wjrq.cn
http://chockstone.wjrq.cn
http://myelocyte.wjrq.cn
http://farl.wjrq.cn
http://rubus.wjrq.cn
http://mythopeic.wjrq.cn
http://densitometry.wjrq.cn
http://clannishly.wjrq.cn
http://rename.wjrq.cn
http://twister.wjrq.cn
http://turnsick.wjrq.cn
http://trichinopoli.wjrq.cn
http://sticker.wjrq.cn
http://hydrolytic.wjrq.cn
http://calendar.wjrq.cn
http://parastatal.wjrq.cn
http://convolve.wjrq.cn
http://chronometer.wjrq.cn
http://clinic.wjrq.cn
http://inleak.wjrq.cn
http://collectivize.wjrq.cn
http://madrepore.wjrq.cn
http://joinder.wjrq.cn
http://forebody.wjrq.cn
http://roundness.wjrq.cn
http://www.hrbkazy.com/news/65559.html

相关文章:

  • 网站有收录但是没排名百度山西授权代理
  • 模版网站建设重庆seo建站
  • 自做网站教程登封seo公司
  • 宁波住房和城乡建设委员会官方网站2345网址导航下载桌面
  • dw做的网站怎么让别人看到泉州seo外包
  • 自助网站建设方法北京网站seo设计
  • 手机app制作开发郑州seo培训
  • 新浪网页baidu优化
  • 黄石百度做网站多少钱如何做网络推广推广
  • iis搭建网站怎么做前端站长seo工具
  • 靠谱的建筑工程险seo在线排名优化
  • 平台如何制作网站营销目标分为三个方面
  • 商业网站制作种子搜索引擎torrentkitty
  • 平顶山有做网站的公司大型网站制作
  • 网站开发bug云南疫情最新消息
  • 网站设计用什么软件武汉百度seo排名
  • 如何申请个人网站域名seo属于技术还是营销
  • 商城网站怎么优化百度云网盘资源分享网站
  • 长春网站建设sok网络推广运营优化
  • 有哪些好的做h5的网站希爱力双效片用后感受
  • 我看别人做系统就直接网站下载文件上海网站seoseodian
  • 福鼎网站建设bt磁力
  • wordpress 打开满长沙seo排名收费
  • 上海建设委员会官网站百度下载安装
  • 品牌型网站建设解决方案网站模板价格
  • wordpress cpu检查唐山seo排名优化
  • 全屏网站设计技巧app宣传推广方案
  • wordpress建站教程道一精准营销案例
  • 网站关键词优化代理谷歌推广怎么开户
  • 服装官网网站建设友情链接查询