{"id":99393,"date":"2026-09-02T15:04:22","date_gmt":"2026-09-02T07:04:22","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/99393.html"},"modified":"2026-09-02T15:04:22","modified_gmt":"2026-09-02T07:04:22","slug":"%e9%a2%98%e7%9b%ae%e5%85%83%e6%95%b0%e6%8d%ae%e7%9a%84%e7%bb%93%e6%9e%84%e5%8c%96%e8%ae%be%e8%ae%a1%ef%bc%9ajson-schema-%e5%9c%a8%e7%ae%97%e6%b3%95%e9%a2%98%e5%ba%93%e7%ae%a1%e7%90%86%e4%b8%ad","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/99393.html","title":{"rendered":"\u9898\u76ee\u5143\u6570\u636e\u7684\u7ed3\u6784\u5316\u8bbe\u8ba1\uff1aJSON Schema \u5728\u7b97\u6cd5\u9898\u5e93\u7ba1\u7406\u4e2d\u7684\u5e94\u7528"},"content":{"rendered":"<h2>\u9898\u76ee\u5143\u6570\u636e\u7684\u7ed3\u6784\u5316\u8bbe\u8ba1&#xff1a;JSON Schema \u5728\u7b97\u6cd5\u9898\u5e93\u7ba1\u7406\u4e2d\u7684\u5e94\u7528<\/h2>\n<h3>\u4e00\u3001\u6df1\u5ea6\u5f15\u8a00\u4e0e\u573a\u666f\u75db\u70b9&#xff1a;\u5f53\u9898\u5e93\u8d8a\u6765\u8d8a\u5927&#xff0c;\u7ef4\u62a4\u6210\u672c\u6307\u6570\u7ea7\u589e\u957f<\/h3>\n<p>\u521a\u5f00\u59cb\u505a\u5237\u9898\u7cfb\u7edf\u65f6&#xff0c;\u9898\u5e93\u53ea\u6709 20 \u9053\u9898\u3002\u9898\u76ee\u7684\u5143\u6570\u636e&#xff08;\u6807\u9898\u3001\u63cf\u8ff0\u3001\u96be\u5ea6\u3001\u6807\u7b7e\u3001\u6d4b\u8bd5\u7528\u4f8b&#xff09;\u76f4\u63a5\u786c\u7f16\u7801\u5728 Java \u4ee3\u7801\u91cc&#xff0c;\u7528\u4e00\u4e2a enum \u5c31\u89e3\u51b3\u4e86\u3002\u4f46\u968f\u7740\u9898\u5e93\u81a8\u80c0\u5230 200 \u9053\u9898\u4ee5\u4e0a&#xff0c;\u5669\u68a6\u5f00\u59cb\u4e86&#xff1a;<\/p>\n<ul>\n<li>\u65b0\u589e\u4e00\u9053\u9898\u9700\u8981\u4fee\u6539 Java \u4ee3\u7801\u3001\u91cd\u65b0\u7f16\u8bd1\u3001\u91cd\u65b0\u90e8\u7f72\u3002\u8fd0\u8425\u540c\u5b66\u60f3\u52a0\u9898&#xff1f;\u627e\u5f00\u53d1\u3002<\/li>\n<li>\u540c\u4e00\u9053\u9898\u9700\u8981\u540c\u65f6\u7ef4\u62a4\u4e2d\u6587\u548c\u82f1\u6587\u7248\u672c&#xff0c;\u4e24\u4e2a\u7248\u672c\u7684\u4e00\u81f4\u6027\u65e0\u6cd5\u4fdd\u8bc1\u3002<\/li>\n<li>\u6d4b\u8bd5\u7528\u4f8b\u7684\u683c\u5f0f\u6ca1\u6709\u7ea6\u675f\u3002\u6709\u4eba\u5199 [1,2,3]&#xff0c;\u6709\u4eba\u5199 1 2 3&#xff0c;\u89e3\u6790\u903b\u8f91\u8d8a\u6765\u8d8a\u590d\u6742\u3002<\/li>\n<li>\u9898\u76ee\u4e4b\u95f4\u7684\u5173\u7cfb&#xff08;\u524d\u7f6e\u9898\u3001\u76f8\u4f3c\u9898\u3001\u8fdb\u9636\u9898&#xff09;\u6563\u843d\u5728\u5404\u5904&#xff0c;\u65e0\u6cd5\u7ed3\u6784\u5316\u67e5\u8be2\u3002<\/li>\n<\/ul>\n<p>\u8fd9\u4e9b\u95ee\u9898\u7684\u6839\u6e90\u5728\u4e8e&#xff1a;\u7f3a\u4e4f\u7edf\u4e00\u7684\u5143\u6570\u636e\u6a21\u578b\u548c\u6821\u9a8c\u673a\u5236\u3002\u800c JSON Schema \u6070\u597d\u662f\u89e3\u51b3\u8fd9\u7c7b\u95ee\u9898\u7684\u6807\u51c6\u5de5\u5177\u3002<\/p>\n<h3>\u4e8c\u3001\u5e95\u5c42\u673a\u5236\u4e0e\u539f\u7406\u6df1\u5ea6\u5256\u6790<\/h3>\n<p>JSON Schema \u662f\u4e00\u5957\u7528\u4e8e\u63cf\u8ff0 JSON \u6570\u636e\u7ed3\u6784\u7684\u89c4\u8303\u8bed\u8a00\u3002\u5b83\u7684\u6838\u5fc3\u4ef7\u503c\u6709\u4e09\u4e2a&#xff1a;<\/p>\n<li>\u7ed3\u6784\u6821\u9a8c&#xff1a;\u5b9a\u4e49\u5b57\u6bb5\u7c7b\u578b\u3001\u5fc5\u586b\/\u53ef\u9009\u3001\u679a\u4e3e\u503c\u3001\u6b63\u5219\u6a21\u5f0f<\/li>\n<li>\u6570\u636e\u7ea6\u675f&#xff1a;\u8303\u56f4\u9650\u5236&#xff08;\u6700\u5c0f\u503c\u3001\u6700\u5927\u503c\u3001\u957f\u5ea6&#xff09;\u3001\u4f9d\u8d56\u5173\u7cfb&#xff08;\u5b57\u6bb5 A \u4e0d\u4e3a\u7a7a\u65f6\u5b57\u6bb5 B \u5fc5\u586b&#xff09;<\/li>\n<li>\u81ea\u6587\u6863\u5316&#xff1a;Schema \u672c\u8eab\u5c31\u662f\u4e00\u4efd\u53ef\u8bfb\u7684\u6570\u636e\u5b57\u5178<\/li>\n<p>\u4e0b\u9762\u662f\u6211\u4eec\u4e3a\u7b97\u6cd5\u9898\u76ee\u8bbe\u8ba1\u7684 JSON Schema \u6838\u5fc3\u7ed3\u6784&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;$schema&#034;: &#034;https:\/\/json-schema.org\/draft\/2020-12\/schema&#034;,<br \/>\n  &#034;$id&#034;: &#034;https:\/\/oj.example.com\/schemas\/problem.schema.json&#034;,<br \/>\n  &#034;type&#034;: &#034;object&#034;,<br \/>\n  &#034;required&#034;: [&#034;id&#034;, &#034;title&#034;, &#034;difficulty&#034;, &#034;content&#034;, &#034;testCases&#034;],<br \/>\n  &#034;properties&#034;: {<br \/>\n    &#034;id&#034;: {}<br \/>\n  }<br \/>\n}<\/p>\n<p>\u5173\u952e\u8bbe\u8ba1\u7406\u5ff5&#xff1a;\u9898\u76ee\u5143\u6570\u636e\u4e0e\u4e1a\u52a1\u903b\u8f91\u89e3\u8026\u3002\u5f00\u53d1\u4e0d\u518d\u9700\u8981\u4e3a\u6bcf\u9053\u9898\u5199\u4ee3\u7801&#xff0c;\u8fd0\u8425\u53ef\u4ee5\u81ea\u52a9\u7ba1\u7406\u9898\u5e93\u3002<\/p>\n<h3>\u4e09\u3001\u751f\u4ea7\u7ea7\u4ee3\u7801\u5b9e\u73b0\u4e0e\u6700\u4f73\u5b9e\u8df5<\/h3>\n<h4>\u9898\u76ee Schema \u7684\u5b8c\u6574\u5b9a\u4e49<\/h4>\n<p>{<br \/>\n  &#034;$schema&#034;: &#034;https:\/\/json-schema.org\/draft\/2020-12\/schema&#034;,<br \/>\n  &#034;title&#034;: &#034;\u7b97\u6cd5\u9898\u76ee\u5143\u6570\u636e&#034;,<br \/>\n  &#034;type&#034;: &#034;object&#034;,<br \/>\n  &#034;required&#034;: [&#034;id&#034;, &#034;title&#034;, &#034;difficulty&#034;, &#034;description&#034;, &#034;testCases&#034;],<br \/>\n  &#034;properties&#034;: {<br \/>\n    &#034;id&#034;: {<br \/>\n      &#034;type&#034;: &#034;string&#034;,<br \/>\n      &#034;pattern&#034;: &#034;^P[0-9]{4}$&#034;,<br \/>\n      &#034;description&#034;: &#034;\u9898\u76ee\u552f\u4e00\u6807\u8bc6&#xff0c;\u683c\u5f0f P0001 ~ P9999&#034;<br \/>\n    },<br \/>\n    &#034;title&#034;: {<br \/>\n      &#034;type&#034;: &#034;string&#034;,<br \/>\n      &#034;minLength&#034;: 5,<br \/>\n      &#034;maxLength&#034;: 100,<br \/>\n      &#034;description&#034;: &#034;\u9898\u76ee\u6807\u9898&#034;<br \/>\n    },<br \/>\n    &#034;difficulty&#034;: {<br \/>\n      &#034;type&#034;: &#034;string&#034;,<br \/>\n      &#034;enum&#034;: [&#034;EASY&#034;, &#034;MEDIUM&#034;, &#034;HARD&#034;],<br \/>\n      &#034;description&#034;: &#034;\u9898\u76ee\u96be\u5ea6\u7b49\u7ea7&#034;<br \/>\n    },<br \/>\n    &#034;tags&#034;: {<br \/>\n      &#034;type&#034;: &#034;array&#034;,<br \/>\n      &#034;items&#034;: { &#034;type&#034;: &#034;string&#034;, &#034;minLength&#034;: 1 },<br \/>\n      &#034;uniqueItems&#034;: true,<br \/>\n      &#034;minItems&#034;: 1,<br \/>\n      &#034;maxItems&#034;: 10,<br \/>\n      &#034;description&#034;: &#034;\u9898\u76ee\u6807\u7b7e&#xff0c;\u81f3\u5c11 1 \u4e2a\u6700\u591a 10 \u4e2a&#xff0c;\u4e0d\u53ef\u91cd\u590d&#034;<br \/>\n    },<br \/>\n    &#034;testCases&#034;: {<br \/>\n      &#034;type&#034;: &#034;array&#034;,<br \/>\n      &#034;items&#034;: {<br \/>\n        &#034;type&#034;: &#034;object&#034;,<br \/>\n        &#034;required&#034;: [&#034;input&#034;, &#034;expectedOutput&#034;],<br \/>\n        &#034;properties&#034;: {<br \/>\n          &#034;input&#034;: { &#034;type&#034;: &#034;string&#034; },<br \/>\n          &#034;expectedOutput&#034;: { &#034;type&#034;: &#034;string&#034; },<br \/>\n          &#034;isHidden&#034;: { &#034;type&#034;: &#034;boolean&#034;, &#034;default&#034;: false },<br \/>\n          &#034;timeLimitMs&#034;: { &#034;type&#034;: &#034;integer&#034;, &#034;minimum&#034;: 100, &#034;default&#034;: 1000 }<br \/>\n        }<br \/>\n      },<br \/>\n      &#034;minItems&#034;: 1,<br \/>\n      &#034;maxItems&#034;: 50<br \/>\n    },<br \/>\n    &#034;relatedProblems&#034;: {<br \/>\n      &#034;type&#034;: &#034;array&#034;,<br \/>\n      &#034;items&#034;: {<br \/>\n        &#034;type&#034;: &#034;object&#034;,<br \/>\n        &#034;required&#034;: [&#034;problemId&#034;, &#034;relation&#034;],<br \/>\n        &#034;properties&#034;: {<br \/>\n          &#034;problemId&#034;: { &#034;type&#034;: &#034;string&#034;, &#034;pattern&#034;: &#034;^P[0-9]{4}$&#034; },<br \/>\n          &#034;relation&#034;: {<br \/>\n            &#034;type&#034;: &#034;string&#034;,<br \/>\n            &#034;enum&#034;: [&#034;PREREQUISITE&#034;, &#034;SIMILAR&#034;, &#034;ADVANCED&#034;]<br \/>\n          }<br \/>\n        }<br \/>\n      }<br \/>\n    }<br \/>\n  }<br \/>\n}<\/p>\n<h4>Java \u7aef\u6821\u9a8c\u5b9e\u73b0<\/h4>\n<p>\/\/ Schema \u6821\u9a8c\u670d\u52a1 \u2014\u2014 \u7edf\u4e00\u5165\u53e3&#xff0c;\u6240\u6709\u9898\u76ee\u5165\u5e93\u524d\u5fc5\u987b\u901a\u8fc7\u6b64\u6821\u9a8c<br \/>\n&#064;Service<br \/>\npublic class ProblemSchemaValidator {<\/p>\n<p>    private final JsonSchema schema;<br \/>\n    private final ObjectMapper objectMapper;<\/p>\n<p>    public ProblemSchemaValidator() throws Exception {<br \/>\n        this.objectMapper &#061; new ObjectMapper();<\/p>\n<p>        \/\/ \u4ece classpath \u52a0\u8f7d Schema \u5b9a\u4e49\u6587\u4ef6<br \/>\n        \/\/ \u8fd9\u6837 Schema \u7248\u672c\u53ef\u4ee5\u72ec\u7acb\u4e8e\u4ee3\u7801\u53d1\u5e03<br \/>\n        String schemaContent &#061; new String(<br \/>\n            Files.readAllBytes(Path.of(<br \/>\n                getClass().getClassLoader()<br \/>\n                    .getResource(&#034;schemas\/problem.schema.json&#034;)<br \/>\n                    .toURI()<br \/>\n            ))<br \/>\n        );<\/p>\n<p>        \/\/ \u4f7f\u7528 networknt\/json-schema-validator \u5e93\u8fdb\u884c\u6821\u9a8c<br \/>\n        JsonSchemaFactory factory &#061; JsonSchemaFactory.getInstance(<br \/>\n            SpecVersion.VersionFlag.V202012<br \/>\n        );<br \/>\n        this.schema &#061; factory.getSchema(schemaContent);<br \/>\n    }<\/p>\n<p>    public ValidationResult validate(String problemJson) {<br \/>\n        try {<br \/>\n            JsonNode node &#061; objectMapper.readTree(problemJson);<br \/>\n            Set&lt;ValidationMessage&gt; errors &#061; schema.validate(node);<\/p>\n<p>            if (errors.isEmpty()) {<br \/>\n                return ValidationResult.success();<br \/>\n            }<\/p>\n<p>            \/\/ \u5c06\u6821\u9a8c\u9519\u8bef\u7ffb\u8bd1\u4e3a\u4eba\u7c7b\u53ef\u8bfb\u7684\u4e2d\u6587\u4fe1\u606f<br \/>\n            \/\/ \u8fd9\u6837\u8fd0\u8425\u540c\u5b66\u80fd\u6e05\u695a\u77e5\u9053\u54ea\u91cc\u586b\u9519\u4e86<br \/>\n            List&lt;String&gt; humanReadableErrors &#061; errors.stream()<br \/>\n                .map(this::translateErrorMessage)<br \/>\n                .collect(Collectors.toList());<\/p>\n<p>            return ValidationResult.failure(humanReadableErrors);<br \/>\n        } catch (JsonProcessingException e) {<br \/>\n            return ValidationResult.failure(<br \/>\n                List.of(&#034;JSON \u683c\u5f0f\u89e3\u6790\u5931\u8d25: &#034; &#043; e.getMessage())<br \/>\n            );<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ \u5c06\u82f1\u6587\u6821\u9a8c\u4fe1\u606f\u8f6c\u6362\u4e3a\u8fd0\u8425\u4eba\u5458\u80fd\u7406\u89e3\u7684\u4e2d\u6587\u63d0\u793a<br \/>\n    private String translateErrorMessage(ValidationMessage msg) {<br \/>\n        \/\/ \u6838\u5fc3\u601d\u8def&#xff1a;\u628a\u6280\u672f\u6027\u7684\u6821\u9a8c\u4fe1\u606f\u7ffb\u8bd1\u4e3a\u4e1a\u52a1\u8bed\u4e49<br \/>\n        String path &#061; msg.getPath();<br \/>\n        String keyword &#061; msg.getKeyword();<\/p>\n<p>        return switch (keyword) {<br \/>\n            case &#034;required&#034; -&gt; String.format(<br \/>\n                &#034;\u5b57\u6bb5 &#096;%s&#096; \u4e3a\u5fc5\u586b\u9879&#xff0c;\u5f53\u524d\u7f3a\u5c11\u8be5\u5b57\u6bb5&#034;, path<br \/>\n            );<br \/>\n            case &#034;enum&#034; -&gt; String.format(<br \/>\n                &#034;\u5b57\u6bb5 &#096;%s&#096; \u7684\u503c\u4e0d\u5728\u5141\u8bb8\u8303\u56f4\u5185&#034;, path<br \/>\n            );<br \/>\n            case &#034;minLength&#034; -&gt; String.format(<br \/>\n                &#034;\u5b57\u6bb5 &#096;%s&#096; \u7684\u957f\u5ea6\u4e0d\u8db3&#xff0c;\u9700\u8981\u81f3\u5c11 %d \u4e2a\u5b57\u7b26&#034;,<br \/>\n                path, msg.getArguments().get(&#034;minLength&#034;).intValue()<br \/>\n            );<br \/>\n            case &#034;pattern&#034; -&gt; String.format(<br \/>\n                &#034;\u5b57\u6bb5 &#096;%s&#096; \u7684\u683c\u5f0f\u4e0d\u7b26\u5408\u8981\u6c42&#xff0c;\u8bf7\u68c0\u67e5\u683c\u5f0f\u89c4\u8303&#034;, path<br \/>\n            );<br \/>\n            default -&gt; String.format(&#034;\u5b57\u6bb5 &#096;%s&#096; \u6821\u9a8c\u5931\u8d25: %s&#034;, path, msg.getMessage());<br \/>\n        };<br \/>\n    }<br \/>\n}<\/p>\n<p># Python \u7aef\u6279\u91cf\u5bfc\u5165\u9898\u76ee\u7684\u811a\u672c \u2014\u2014 \u652f\u6301\u4ece Markdown \u81ea\u52a8\u751f\u6210\u9898\u76ee JSON<br \/>\nimport json<br \/>\nimport re<br \/>\nfrom pathlib import Path<br \/>\nfrom jsonschema import validate, ValidationError<\/p>\n<p># \u52a0\u8f7d Schema&#xff08;\u4e0e Java \u7aef\u4f7f\u7528\u540c\u4e00\u4efd\u5b9a\u4e49&#xff0c;\u4fdd\u8bc1\u6821\u9a8c\u4e00\u81f4\u6027&#xff09;<br \/>\nSCHEMA_PATH &#061; Path(__file__).parent \/ &#034;schemas&#034; \/ &#034;problem.schema.json&#034;<br \/>\nwith open(SCHEMA_PATH) as f:<br \/>\n    SCHEMA &#061; json.load(f)<\/p>\n<p>def parse_problem_from_markdown(md_path: str) -&gt; dict:<br \/>\n    &#034;&#034;&#034;\u4ece Markdown \u6587\u4ef6\u89e3\u6790\u9898\u76ee\u5143\u6570\u636e<\/p>\n<p>    Markdown \u683c\u5f0f\u7ea6\u5b9a&#xff1a;<br \/>\n    # P0001 \u4e24\u6570\u4e4b\u548c<br \/>\n    &#8211; \u96be\u5ea6: EASY<br \/>\n    &#8211; \u6807\u7b7e: \u6570\u7ec4, \u54c8\u5e0c\u8868<\/p>\n<p>    ## \u9898\u76ee\u63cf\u8ff0<br \/>\n    &#8230;<\/p>\n<p>    ## \u6d4b\u8bd5\u7528\u4f8b<br \/>\n    &#8211; \u8f93\u5165: [2,7,11,15], 9 \u2192 \u8f93\u51fa: [0,1]<br \/>\n    &#034;&#034;&#034;<br \/>\n    content &#061; Path(md_path).read_text(encoding&#061;&#034;utf-8&#034;)<\/p>\n<p>    # \u89e3\u6790\u6807\u9898\u884c<br \/>\n    title_match &#061; re.match(r&#034;^# (P\\\\d{4})\\\\s&#043;(.&#043;)$&#034;, content, re.MULTILINE)<br \/>\n    if not title_match:<br \/>\n        raise ValueError(f&#034;\u65e0\u6cd5\u89e3\u6790\u9898\u76ee ID \u548c\u6807\u9898: {md_path}&#034;)<br \/>\n    problem_id, title &#061; title_match.groups()<\/p>\n<p>    # \u89e3\u6790\u96be\u5ea6\u548c\u6807\u7b7e<br \/>\n    difficulty &#061; re.search(r&#034;\u96be\u5ea6:\\\\s*(EASY|MEDIUM|HARD)&#034;, content).group(1)<br \/>\n    tags_line &#061; re.search(r&#034;\u6807\u7b7e:\\\\s*(.&#043;)$&#034;, content, re.MULTILINE).group(1)<br \/>\n    tags &#061; [t.strip() for t in tags_line.split(&#034;,&#034;)]<\/p>\n<p>    return {<br \/>\n        &#034;id&#034;: problem_id,<br \/>\n        &#034;title&#034;: title,<br \/>\n        &#034;difficulty&#034;: difficulty,<br \/>\n        &#034;tags&#034;: tags,<br \/>\n        &#034;description&#034;: &#034;&#8230;&#034;,<br \/>\n        &#034;testCases&#034;: [&#8230;]<br \/>\n    }<\/p>\n<p>def batch_import(problems_dir: str):<br \/>\n    &#034;&#034;&#034;\u6279\u91cf\u5bfc\u5165\u9898\u76ee\u76ee\u5f55\u4e0b\u7684\u6240\u6709 Markdown \u6587\u4ef6&#034;&#034;&#034;<br \/>\n    success, failed &#061; 0, 0<br \/>\n    for md_file in Path(problems_dir).glob(&#034;*.md&#034;):<br \/>\n        try:<br \/>\n            problem &#061; parse_problem_from_markdown(str(md_file))<br \/>\n            validate(instance&#061;problem, schema&#061;SCHEMA)  # Schema \u6821\u9a8c<br \/>\n            # \u6821\u9a8c\u901a\u8fc7\u540e&#xff0c;\u5199\u5165\u6570\u636e\u5e93\u6216 JSON \u6587\u4ef6<br \/>\n            save_to_database(problem)<br \/>\n            success &#043;&#061; 1<br \/>\n        except ValidationError as e:<br \/>\n            print(f&#034;[\u6821\u9a8c\u5931\u8d25] {md_file.name}: {e.message}&#034;)<br \/>\n            failed &#043;&#061; 1<br \/>\n    print(f&#034;\u5bfc\u5165\u5b8c\u6210: \u6210\u529f {success} \u9053, \u5931\u8d25 {failed} \u9053&#034;)<\/p>\n<h3>\u56db\u3001\u8fb9\u754c\u5206\u6790\u4e0e\u67b6\u6784\u6743\u8861<\/h3>\n<h4>Schema \u7684\u7248\u672c\u7ba1\u7406<\/h4>\n<p>Schema \u4e0d\u662f\u4e00\u6210\u4e0d\u53d8\u7684\u3002\u5f53\u9700\u8981\u65b0\u589e\u5b57\u6bb5&#xff08;\u6bd4\u5982\u589e\u52a0&#034;\u9898\u76ee\u6765\u6e90&#034;\u5b57\u6bb5&#xff09;\u65f6&#xff0c;\u9700\u8981\u8003\u8651\u51e0\u4e2a\u95ee\u9898&#xff1a;<\/p>\n<ul>\n<li>\u5411\u540e\u517c\u5bb9&#xff1a;\u65b0\u5b57\u6bb5\u5e94\u8be5\u8bbe\u7f6e\u4e3a\u53ef\u9009&#xff08;\u975e required&#xff09;&#xff0c;\u8fd9\u6837\u65e7\u6570\u636e\u4e0d\u9700\u8981\u7acb\u5373\u8fc1\u79fb<\/li>\n<li>\u6570\u636e\u8fc1\u79fb&#xff1a;\u5f53\u5b57\u6bb5\u4ece\u53ef\u9009\u53d8\u5fc5\u586b\u65f6&#xff0c;\u9700\u8981\u63d0\u4f9b\u9ed8\u8ba4\u503c\u6216\u6279\u91cf\u56de\u586b\u811a\u672c<\/li>\n<li>\u6d88\u8d39\u8005\u901a\u77e5&#xff1a;\u5224\u9898\u670d\u52a1\u3001\u524d\u7aef\u5c55\u793a\u9875\u9762\u90fd\u662f Schema \u7684\u6d88\u8d39\u8005&#xff0c;Schema \u53d8\u66f4\u9700\u8981\u63d0\u524d\u901a\u77e5<\/li>\n<\/ul>\n<h4>\u4e3a\u4ec0\u4e48\u4e0d\u76f4\u63a5\u7528\u6570\u636e\u5e93\u8868\u7ed3\u6784&#xff1f;<\/h4>\n<p>\u6709\u4eba\u4f1a\u95ee&#xff1a;\u65e2\u7136\u6570\u636e\u6700\u7ec8\u5b58\u5728\u6570\u636e\u5e93\u91cc&#xff0c;\u4e3a\u4ec0\u4e48\u4e0d\u76f4\u63a5\u7528\u6570\u636e\u5e93\u7684 DDL \u6765\u7ea6\u675f\u5b57\u6bb5&#xff1f;\u7b54\u6848\u6709\u4e09&#xff1a;<\/p>\n<li>Schema \u7684\u6d88\u8d39\u65b9\u4e0d\u53ea\u6709\u6570\u636e\u5e93&#xff1a;\u524d\u7aef\u8868\u5355\u3001\u5224\u9898\u670d\u52a1\u3001\u6279\u91cf\u5bfc\u5165\u811a\u672c\u90fd\u9700\u8981\u6821\u9a8c&#xff0c;JSON Schema \u53ef\u4ee5\u5728\u591a\u5904\u590d\u7528<\/li>\n<li>\u6570\u636e\u5e93\u53d8\u66f4\u76f8\u5bf9&#034;\u91cd&#034;&#xff1a;ALTER TABLE \u9700\u8981\u9501\u8868&#xff0c;\u800c Schema \u6587\u4ef6\u66f4\u65b0\u540e\u53ea\u9700\u91cd\u542f\u670d\u52a1<\/li>\n<li>Schema \u5929\u7136\u652f\u6301\u7248\u672c\u63a7\u5236&#xff1a;\u653e\u5728 Git \u4ed3\u5e93\u91cc&#xff0c;\u6bcf\u6b21\u53d8\u66f4\u90fd\u6709\u8bb0\u5f55&#xff0c;\u65b9\u4fbf\u95ee\u9898\u8ffd\u6eaf<\/li>\n<h4>\u4e3a\u4ec0\u4e48\u4e0d\u76f4\u63a5\u7528 YAML&#xff1f;<\/h4>\n<p>YAML \u5bf9\u4eba\u7c7b\u66f4\u53cb\u597d&#xff0c;\u4f46\u5728\u7a0b\u5e8f\u4e2d\u5904\u7406\u65f6\u6709\u51e0\u4e2a\u5751&#xff1a;<\/p>\n<ul>\n<li>\u7f29\u8fdb\u654f\u611f&#xff0c;\u5bb9\u6613\u51fa\u73b0\u96be\u4ee5\u6392\u67e5\u7684\u683c\u5f0f\u9519\u8bef<\/li>\n<li>yes\/no \u4f1a\u88ab\u89e3\u6790\u4e3a\u5e03\u5c14\u503c true\/false<\/li>\n<li>\u4e0d\u50cf JSON \u90a3\u6837\u6709\u539f\u751f\u7684 Schema \u6821\u9a8c\u751f\u6001<\/li>\n<\/ul>\n<h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<p>\u9898\u76ee\u5143\u6570\u636e\u7684\u7ed3\u6784\u5316\u8bbe\u8ba1\u770b\u4f3c\u662f\u4e00\u4e2a&#034;\u7ec6\u8282\u95ee\u9898&#034;&#xff0c;\u4f46\u5b83\u76f4\u63a5\u51b3\u5b9a\u4e86\u9898\u5e93\u7cfb\u7edf\u7684\u53ef\u7ef4\u62a4\u6027\u3002\u5f53\u9898\u76ee\u6570\u91cf\u4ece 20 \u9053\u589e\u957f\u5230 2000 \u9053\u65f6&#xff0c;\u8bbe\u8ba1\u826f\u597d\u7684\u5143\u6570\u636e\u6a21\u578b\u80fd\u8ba9\u4f60\u4fdd\u6301\u4ece\u5bb9\u3002<\/p>\n<p>JSON Schema \u4e0d\u662f\u94f6\u5f39&#xff0c;\u4f46\u5b83\u89e3\u51b3\u4e86\u9898\u5e93\u7ba1\u7406\u4e2d\u6700\u6838\u5fc3\u7684\u4e09\u4e2a\u95ee\u9898&#xff1a;\u683c\u5f0f\u7edf\u4e00\u3001\u81ea\u52a8\u6821\u9a8c\u3001\u81ea\u52a9\u7ba1\u7406\u3002\u8fd0\u8425\u540c\u5b66\u53ef\u4ee5\u81ea\u5df1\u7f16\u5199\u9898\u76ee&#xff0c;\u63d0\u4ea4\u540e\u81ea\u52a8\u6821\u9a8c&#xff1b;\u5f00\u53d1\u4e0d\u518d\u9700\u8981\u4e3a\u6bcf\u9053\u65b0\u9898\u5199\u6a21\u677f\u4ee3\u7801&#xff1b;\u6240\u6709\u6d88\u8d39\u8005\u90fd\u80fd\u4fe1\u4efb\u6570\u636e\u7684\u5b8c\u6574\u6027\u3002<\/p>\n<p>\u5982\u679c\u53ea\u80fd\u7ed9\u4e00\u4e2a\u5efa\u8bae&#xff1a;\u4ece\u7b2c\u4e00\u9053\u9898\u5f00\u59cb\u5c31\u7528 Schema \u7ea6\u675f\u3002\u4e8b\u540e\u8865 Schema \u7684\u6210\u672c&#xff0c;\u8fdc\u8fdc\u9ad8\u4e8e\u4e00\u5f00\u59cb\u5c31\u89c4\u8303\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u5143\u6570\u636e\u7684\u7ed3\u6784\u5316\u8bbe\u8ba1&#xff1a;JSON Schema \u5728\u7b97\u6cd5\u9898\u5e93\u7ba1\u7406\u4e2d\u7684\u5e94\u7528<br \/>\n\u4e00\u3001\u6df1\u5ea6\u5f15\u8a00\u4e0e\u573a\u666f\u75db\u70b9&#xff1a;\u5f53\u9898\u5e93\u8d8a\u6765\u8d8a\u5927&#xff0c;\u7ef4\u62a4\u6210\u672c\u6307\u6570\u7ea7\u589e\u957f<br \/>\n\u521a\u5f00\u59cb\u505a\u5237\u9898\u7cfb\u7edf\u65f6&#xff0c;\u9898\u5e93\u53ea\u6709 20 \u9053\u9898\u3002\u9898\u76ee\u7684\u5143\u6570\u636e&#xff08;\u6807\u9898\u3001\u63cf\u8ff0\u3001\u96be\u5ea6\u3001\u6807\u7b7e\u3001\u6d4b\u8bd5\u7528\u4f8b&#xff09;\u76f4\u63a5\u786c\u7f16\u7801\u5728 Java \u4ee3\u7801\u91cc&#xff0c;\u7528\u4e00\u4e2a enum \u5c31\u89e3\u51b3\u4e86\u3002\u4f46\u968f\u7740\u9898\u5e93\u81a8\u80c0\u5230 200 \u9053\u9898\u4ee5\u4e0a&#xff0c;\u5669\u68a6\u5f00\u59cb\u4e86&#xff1a;<br \/>\n\u65b0\u589e\u4e00\u9053\u9898\u9700\u8981\u4fee\u6539 J<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2692,4323,427],"topic":[],"class_list":["post-99393","post","type-post","status-publish","format-standard","hentry","category-server","tag-leetcode","tag-4323","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u9898\u76ee\u5143\u6570\u636e\u7684\u7ed3\u6784\u5316\u8bbe\u8ba1\uff1aJSON Schema \u5728\u7b97\u6cd5\u9898\u5e93\u7ba1\u7406\u4e2d\u7684\u5e94\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/99393.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u9898\u76ee\u5143\u6570\u636e\u7684\u7ed3\u6784\u5316\u8bbe\u8ba1\uff1aJSON Schema \u5728\u7b97\u6cd5\u9898\u5e93\u7ba1\u7406\u4e2d\u7684\u5e94\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u9898\u76ee\u5143\u6570\u636e\u7684\u7ed3\u6784\u5316\u8bbe\u8ba1&#xff1a;JSON Schema \u5728\u7b97\u6cd5\u9898\u5e93\u7ba1\u7406\u4e2d\u7684\u5e94\u7528 \u4e00\u3001\u6df1\u5ea6\u5f15\u8a00\u4e0e\u573a\u666f\u75db\u70b9&#xff1a;\u5f53\u9898\u5e93\u8d8a\u6765\u8d8a\u5927&#xff0c;\u7ef4\u62a4\u6210\u672c\u6307\u6570\u7ea7\u589e\u957f \u521a\u5f00\u59cb\u505a\u5237\u9898\u7cfb\u7edf\u65f6&#xff0c;\u9898\u5e93\u53ea\u6709 20 \u9053\u9898\u3002\u9898\u76ee\u7684\u5143\u6570\u636e&#xff08;\u6807\u9898\u3001\u63cf\u8ff0\u3001\u96be\u5ea6\u3001\u6807\u7b7e\u3001\u6d4b\u8bd5\u7528\u4f8b&#xff09;\u76f4\u63a5\u786c\u7f16\u7801\u5728 Java \u4ee3\u7801\u91cc&#xff0c;\u7528\u4e00\u4e2a enum \u5c31\u89e3\u51b3\u4e86\u3002\u4f46\u968f\u7740\u9898\u5e93\u81a8\u80c0\u5230 200 \u9053\u9898\u4ee5\u4e0a&#xff0c;\u5669\u68a6\u5f00\u59cb\u4e86&#xff1a; \u65b0\u589e\u4e00\u9053\u9898\u9700\u8981\u4fee\u6539 J\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/99393.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-02T07:04:22+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/99393.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/99393.html\",\"name\":\"\u9898\u76ee\u5143\u6570\u636e\u7684\u7ed3\u6784\u5316\u8bbe\u8ba1\uff1aJSON Schema \u5728\u7b97\u6cd5\u9898\u5e93\u7ba1\u7406\u4e2d\u7684\u5e94\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-02T07:04:22+00:00\",\"dateModified\":\"2026-09-02T07:04:22+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/99393.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/99393.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/99393.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u9898\u76ee\u5143\u6570\u636e\u7684\u7ed3\u6784\u5316\u8bbe\u8ba1\uff1aJSON Schema \u5728\u7b97\u6cd5\u9898\u5e93\u7ba1\u7406\u4e2d\u7684\u5e94\u7528\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u9898\u76ee\u5143\u6570\u636e\u7684\u7ed3\u6784\u5316\u8bbe\u8ba1\uff1aJSON Schema \u5728\u7b97\u6cd5\u9898\u5e93\u7ba1\u7406\u4e2d\u7684\u5e94\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/99393.html","og_locale":"zh_CN","og_type":"article","og_title":"\u9898\u76ee\u5143\u6570\u636e\u7684\u7ed3\u6784\u5316\u8bbe\u8ba1\uff1aJSON Schema \u5728\u7b97\u6cd5\u9898\u5e93\u7ba1\u7406\u4e2d\u7684\u5e94\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u9898\u76ee\u5143\u6570\u636e\u7684\u7ed3\u6784\u5316\u8bbe\u8ba1&#xff1a;JSON Schema \u5728\u7b97\u6cd5\u9898\u5e93\u7ba1\u7406\u4e2d\u7684\u5e94\u7528 \u4e00\u3001\u6df1\u5ea6\u5f15\u8a00\u4e0e\u573a\u666f\u75db\u70b9&#xff1a;\u5f53\u9898\u5e93\u8d8a\u6765\u8d8a\u5927&#xff0c;\u7ef4\u62a4\u6210\u672c\u6307\u6570\u7ea7\u589e\u957f \u521a\u5f00\u59cb\u505a\u5237\u9898\u7cfb\u7edf\u65f6&#xff0c;\u9898\u5e93\u53ea\u6709 20 \u9053\u9898\u3002\u9898\u76ee\u7684\u5143\u6570\u636e&#xff08;\u6807\u9898\u3001\u63cf\u8ff0\u3001\u96be\u5ea6\u3001\u6807\u7b7e\u3001\u6d4b\u8bd5\u7528\u4f8b&#xff09;\u76f4\u63a5\u786c\u7f16\u7801\u5728 Java \u4ee3\u7801\u91cc&#xff0c;\u7528\u4e00\u4e2a enum \u5c31\u89e3\u51b3\u4e86\u3002\u4f46\u968f\u7740\u9898\u5e93\u81a8\u80c0\u5230 200 \u9053\u9898\u4ee5\u4e0a&#xff0c;\u5669\u68a6\u5f00\u59cb\u4e86&#xff1a; \u65b0\u589e\u4e00\u9053\u9898\u9700\u8981\u4fee\u6539 J","og_url":"https:\/\/www.wsisp.com\/helps\/99393.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-02T07:04:22+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/99393.html","url":"https:\/\/www.wsisp.com\/helps\/99393.html","name":"\u9898\u76ee\u5143\u6570\u636e\u7684\u7ed3\u6784\u5316\u8bbe\u8ba1\uff1aJSON Schema \u5728\u7b97\u6cd5\u9898\u5e93\u7ba1\u7406\u4e2d\u7684\u5e94\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-02T07:04:22+00:00","dateModified":"2026-09-02T07:04:22+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/99393.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/99393.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/99393.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u9898\u76ee\u5143\u6570\u636e\u7684\u7ed3\u6784\u5316\u8bbe\u8ba1\uff1aJSON Schema \u5728\u7b97\u6cd5\u9898\u5e93\u7ba1\u7406\u4e2d\u7684\u5e94\u7528"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/99393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=99393"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/99393\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=99393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=99393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=99393"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=99393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}