1

目标是将 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 (但这会使反序列化变得困难)
  3. 这是否符合 JSONSchema 规范。

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

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

4

1 回答 1

1
     "SimpleObjectAttributeGroup": {          
            {
              "id":{
                     "type":"sometype"
properties of id go here 
                    }
            },
          ....and more properties 
         }
This seems to be the correct JOSNSchema.
于 2011-12-27T13:38:09.853 回答