In my c# program I am using Newtonsoft to convert an xml to json.
I would like to convert a single node(version) from the following XML to an array since in most cases there are multiple nodes. When there are multiple versions the json converter automatically creates an array but doesn't when single.
I would like to force single version elements to arrays to use Angular ng-repeat consistently
Here is the XML
<versions>
<testmode>true</testmode>
<type>default</type>
<version name="Test" url="http://myurl" />
</versions>
Which I convert with:
JsonConvert.SerializeXNode(xdoc);
When converted the json looks like:
"{\"Versions\":{\"testmode\":\"true\",\"type\":\"default\",\"version\":{\"name\":\"Test\",\"url\":\"http://myurl\"}}}"
I would like the version to be inside an array as:
"{\"Versions\":{\"testmode\":\"true\",\"type\":\"default\",\"version\":[{\"name\":\"Test\",\"url\":\"http://myurl\"}]}}"