jackson-dataformat-xml
jackson-dataformat-xml copied to clipboard
xml数组个数转换错误
转换后当前是:
应该是:


Screenshots are bit problematic (I can't see the code), and without any description it is difficult to know if I understand the issue... but if the problem is that XML token stream model produces repeat keys, yes, this is true. Use of token stream level API is not something that is supported for general usage, and users need to be aware of some oddities there.
But I think that if you want to produce valid JSON from XML, you will need to either:
- Use an intermediate structure to read XML -- for example,
JsonNodefromObjectMapper.readTree()-- and then write that. Binding toJsonNodeorObject, with Jackson 2.12.3, should produce Arrays for repeated elements - If using streaming API directly, add handling of duplicate keys; most likely to create implicit Array. This is what
JsonNodeDeserializerdoes (as of Jackson 2.12)