I am using JSON.NET to convert some XML to JSON.
My XML looks like this:
<Root>
<Product>
<Name />
<Id />
</Product>
<Product>
<Name />
<Id />
</Product>
</Root>
Im converting the xml using this method:
private string ConvertToJson(string xml)
{
XmlDocument XmlDoc = new XmlDocument();
XmlDoc.LoadXml(xml);
var JsonString = JsonConvert.SerializeXmlNode(XmlDoc);
return JsonString;
}
This works fine as long as there is more than one product, JSON.NET will create a JSON array. However if there is only one product JSON.NET will not create a JSON array, but i need it to.
Any way to force it to create a JSON array?