I am facing an issue in converting XML to JSON
My input xml is
<Message>
<Sequence id="S">
<Tag id="T1"></Tag>
<Sequence id="S1">
<Tag id="T2"></Tag>
</Sequence>
<Tag id="T3"></Tag>
</Sequence>
</Message>
I am using NewtonSoft JsonConvert to convert it to Json
The converted Json is like this, all elements with name 'Tag' are grouped into one array, They should be grouped into multiple seperate 'Tag' arrays at same level
"Message": {
"Sequence": {
"@id": "S",
"Tag": [
{
"@id": "T1"
},
{
"@id": "T3"
}
],
"Sequence": {
"@id": "S1",
"Tag": {
"@id": "T2"
}
}
}
}
I am expecting the conversion to be
"Message": {
"Sequence": {
"@id": "S",
"Tag": [
{
"@id": "T1"
}
],
"Sequence": {
"@id": "S1",
"Tag": {
"@id": "T2"
}
},
"Tag": [
{
"@id": "T3"
}
]
}
}
Please let me know your thoughts on how to fix this