.NET RestSharp反序列化:自定义字段名称 [英] .net RestSharp Deserialization: custom field name
本文介绍了.NET RestSharp反序列化:自定义字段名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想反序列化的下列对象:
I'm trying to deserialize the following object:
{
"start_time": "2013-05-21T10:58:32Z",
"result": 1,
"message": " ok",
"operator": "http://127.0.0.1:8000/api/users/2/"
}
如何写这个对象的C#模式? 操作员关键字不能作为型号名称,我还没有发现可以以图的名称可以使用任何属性。
How to write a C# model of this object? The "operator" keyword cannot be used as model name and I haven't found any Attribute that can be used in order to map the name.
任何想法?
推荐答案
在猜测:
public class SomeType {
public DateTime start_time {get;set;}
public int result {get;set;}
public string message {get;set;}
public string @operator {get;set;}
}
在 @
preFIX可以用来逃避任何C#的关键字; @int
, @string
, @for
等
The @
prefix can be used to escape any C# keyword; @int
, @string
, @for
etc.
这篇关于.NET RestSharp反序列化:自定义字段名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文