问题
The objective is to convert an XSD schema to JSON Schema. I am first trying to XSD to JSON and then see if i can fix the JSON to become JSON Schema.All this procedure is because right now i don't know a direct way of converting XSD to JSON Schema. Consider the following fragment for now. i have the following fragment of XSD
<attributeGroup name="SimpleObjectAttributeGroup">
<attribute ref="s:id"/>
<attribute ref="s:metadata"/>
<attribute ref="s:linkMetadata"/>
</attributeGroup>
The corresponding JSON i get is
"attributeGroup": {
"name": "SimpleObjectAttributeGroup",
"attribute": [
{
"ref": "s:id"
},
{
"ref": "s:metadata"
},
{
"ref": "s:linkMetadata"
}
]
}
So my question is
- is this right ?
- Should i override the attribue ref as $ref instead of @ref (but that would make de serialization tough )
- Is this conforming to the JSONSchema specification.
The specification can be found at http://json-schema.org/
i used c# and Json.net to achieve this.
回答1:
"SimpleObjectAttributeGroup": {
{
"id":{
"type":"sometype"
properties of id go here
}
},
....and more properties
}
This seems to be the correct JOSNSchema.
来源:https://stackoverflow.com/questions/7950702/is-this-correct-jsonschema-json-for-the-xsd