【问题标题】:Is this correct JSONSchema/Json for the XSD?这是 XSD 的正确 JSONSchema/Json 吗?
【发布时间】:2011-12-18 12:56:28
【问题描述】:

目标是将 XSD 架构转换为 JSON 架构。 我首先尝试将 XSD 转换为 JSON,然后看看我是否可以将 JSON 修复为 JSON Schema。所有这些过程都是因为现在我不知道将 XSD 转换为 JSON Schema 的直接方法。 现在考虑以下片段。 我有以下 XSD 片段

<attributeGroup name="SimpleObjectAttributeGroup">
    <attribute ref="s:id"/>
    <attribute ref="s:metadata"/>
    <attribute ref="s:linkMetadata"/>
  </attributeGroup>

我得到的对应的JSON是

 "attributeGroup": {
      "name": "SimpleObjectAttributeGroup",
      "attribute": [
        {
          "ref": "s:id"
        },
        {
          "ref": "s:metadata"
        },
        {
          "ref": "s:linkMetadata"
        }
      ]
    }

所以我的问题是

  1. 是这样吗?
  2. 我是否应该将属性 ref 覆盖为 $ref 而不是 @ref(但是 会使反序列化变得困难)
  3. 这是否符合 JSONSchema 规范。

规范可以在http://json-schema.org/找到

我使用 c# 和 Json.net 来实现这一点。

【问题讨论】:

  • 如果您正在寻找将 XSD 转换为 JSON 模式的直接方法,您可以查看以下问题:stackoverflow.com/questions/3922026/…
  • 它没有做我想做的事,我已经深入研究了几个星期..
  • 我问了这个问题stackoverflow.com/questions/8063811/…,这是我在做你的想法时遇到的许多问题之一。
  • 请注意,JSON 不是有效的 JSON,应该在整个内容周围加上括号 {} 以使其成为 JSON 对象。
  • chris ...我刚刚发布了整个 json 的一小部分,我确实有 {} 围绕着整个内容..由于空间限制,我没有粘贴整个内容

标签: json xsd jsonschema


【解决方案1】:
     "SimpleObjectAttributeGroup": {          
            {
              "id":{
                     "type":"sometype"
properties of id go here 
                    }
            },
          ....and more properties 
         }
This seems to be the correct JOSNSchema.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-11
    • 2015-06-26
    相关资源
    最近更新 更多