C# 将元素名称反序列化为RestSharp中的属性
不幸的是,我查询的API返回的XML如下:C# 将元素名称反序列化为RestSharp中的属性,c#,restsharp,C#,Restsharp,不幸的是,我查询的API返回的XML如下: <coupon> <discount_in_cents> <USD type="integer">500</USD> <EUR type="integer">450</EUR> </discount_in_cents> </coupon> 我有一个我正在尝试填充的列表 public List<Discount>
<coupon>
<discount_in_cents>
<USD type="integer">500</USD>
<EUR type="integer">450</EUR>
</discount_in_cents>
</coupon>
我有一个我正在尝试填充的列表
public List<Discount> {get;set;}
public class Discount
{
public string CurrencyType {get;set;}
public int Value {get;set;}
}
Value属性设置正确,但我需要在CurrencyType属性(如CurrencyType=USD)中填充元素名称。如何让RestSharp用元素名填充CurrencyType?您可以尝试使用[XmlRoot]和[XmlElement]属性来设置类和xml之间的依赖关系