我目前正在将xml和xsd格式转换为JSON模式,然后在html中绘制树结构,如下所示:
void method(int a)
{
int b = get(a);
if ( b == 0 )
{
throw new NullReferenceException();
}
}
我假设只有|root-
|child1:string
|child2:object
|child21:number
|child3:string
|child4:object
|child41:object
|child411:string
|child42:string
和object
类型的元素是父元素,而其他元素是叶元素(父节点和叶节点的操作方式不同)。在JSON模式array
中,类型元素的子元素将位于object
内,properties
类型元素的子元素将位于array
中。
但是我遇到了以下xml,一个带属性的元素,如何在JSON模式中表示它们?
items
如果以下<shoesize country="france">abcd</shoesize>
为WHAT-TYPE
,则树状图代码不会将其识别为父级,如果是string
,则类型错误。在JSON模式中表示它的正确和最佳方法是什么?
object
或者shoesize:{
type:WHAT-TYPE
properties:{
country:{
type:"string"
}
}
}
是否应更改为properties
并更改树形图代码以检测attributes
?