在JSON模式中使用文本和属性表示xml

时间:2016-11-18 05:21:37

标签: javascript json xml xsd

我目前正在将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

0 个答案:

没有答案