我正在使用JSONIX来传递来自其他系统的XML。我想要的XML
<charge>392.2361<formatted>392.24</formatted></charge>
我仍然想不出如何解开"392.2361“这个值。有什么想法吗?提前感谢
发布于 2017-12-11 07:24:25
这里你需要的是一个混合性质。
{
type: 'classInfo',
localName: 'MyType',
propertyInfos: [{
type: 'elementRef',
name: 'charge',
elementName: 'formatted',
collection : true,
mixed: true
}]
}你所得到的价值是这样的:
[ '392.2361', { name: { localPart: 'formatted' }, value: '392.24' }]没有测试,没有保证,但你知道这个想法。
发布于 2017-12-14 04:19:58
最后正确地应用了它。谢谢你#词汇
下面是我对混合属性的实现
{
type: 'classInfo',
localName: 'ItemizedForDateType', //<date>
propertyInfos:[
{
type: 'element',
name: 'priceTextType',
elementName: 'price',
typeInfo: 'DOTWXML.PriceFormattedType'
},
{
type: 'element',
name: 'priceMinSellTextType',
elementName: 'priceMinimumSelling',
typeInfo: 'DOTWXML.PriceFormattedType'
}
]
},
{
type: 'classInfo',
localName: 'PriceFormattedType',
propertyInfos:[
{
type: 'elementRef',
name: 'charge',
elementName: 'formatted',
collection : true,
mixed: true
},
]
}结果如下所示:
"itemizedForDateType": [
{
"TYPE_NAME": "DOTWXML.ItemizedForDateType",
"priceTextType": {
"TYPE_NAME": "DOTWXML.PriceFormattedType",
"charge": [
"236.8738",
{
"name": {
"namespaceURI": "",
"localPart": "formatted",
"prefix": "",
"key": "formatted",
"string": "formatted"
},
"value": "236.87"
}
]
}
}
]我做了一个错误,删除了“集合:真”,并得到了"{}“。一旦我意识到“集合:真正的”是必需的,就把它放在上下文中,并正确地对所有内容进行处理。
https://stackoverflow.com/questions/47714370
复制相似问题