@sancelot posted a comment with a link to a github stylesheet which I tested alongside the answered instance (I upvoted). Additional detail here to show the following examples.
Example XML:
220
647
0
If I have a mixed attribute node value and use the upvoted answer I get the following output:
"avpList": {
"eComStringAttributeValuePairList": [
{
"attributeName": "orderTypeCode",
"qualifierCodeName": "order",
"qualifierCodeList": "OrderTypeCode",
"qualifierCodeListVersion": "2",
},
{
"attributeName": "orderPriority",
},
{
"attributeName": "customerDocumentReference",
}
]
}
Running it though JSONLint shows the issues with the trailing commas in addition to the missing element value.
Error: Parse error on line 30: ...Version": "2", }
Scripts parsed using XML Spy 2019.
Using the commented Github link and parsing produces the following JSON which validates on first pass through the linter. Please note that if you're expected any form of typed data in your JSON, neither stylesheets do it.
"avpList": {
"eComStringAttributeValuePairList": [
{
"attributeName": "orderTypeCode",
"qualifierCodeName": "order",
"qualifierCodeList": "OrderTypeCode",
"qualifierCodeListVersion": "2",
"text": "220"
},
{
"attributeName": "orderPriority",
"text": "647"
},
{
"attributeName": "customerDocumentReference",
"text": "0"
}
]
}