node.js – How to generate xml doc from json object with nested array?
I am trying to generate xml doc from js object in env node.js. My js object likes:
{
"root": {
"id": 12,
"title": "root title",
"people": [
{"id": 33,"name": "Bill"},
{"id": 34,"name": "Elon"}
],
"camps":[
{"id":1,"addr":"in mountain"},
{"id":2,"addr":"t lake"}
]
}
}
the expected xml is:
I have tried some libs, their result likes below. They all split array into multiple elements with excessive wrapping. That leads to losing the hierachical relations and the result looks illogical.
12
root title
33
Bill
34
Elon
1
In mountant
1
At lake
Read more here: Source link
