I receive a variable called productos
that contains a list of products in JSON
format in the following way:
[{"codigo":"Servilleta","cantidad":2},{"codigo":"Papelhig","cantidad":1}]
I need to deserialize it in order to use the products separately within the method.
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
public XmlDocument prueba(string cliente, string productos)
{
XmlDocument xml = new XmlDocument();
var stringdata = "<items>";
stringdata += "<item>";
stringdata += "<cliente> " + cliente + "</cliente>";
stringdata += "<producto> " + productos + "</producto>";
stringdata += "</item>";
stringdata += "</items>";
xml.LoadXml(stringdata);
return xml;
}