0

首先,让我们看一下这个示例代码

public class SomeRequest
{
    [JsonProperty("_desc")]
    public string Description {get;set;}

    [JsonProperty("_index")]
    public int StartIndex {get;set;}
}
.
.
.
public HttpResponseMessage Get([FromUri] SomeRequest request)
{
...
}

好吧,对于 POST 方法,SomeRequest 已完全反序列化,并且我使用了自定义名称(_index 和 _desc),顺便说一句,这不是好名称,但我只是想表达我的观点。但是,当使用 GET 方法时,必须在 uri 中使用属性的全名,因为使用 FromUri 的格式化程序,而 POST 方法使用 JsonFormatter。所以我只是在寻找一种方法来为这个格式化程序使用自定义名称,就像我在 POST 方法中为 Json 所做的那样。

谢谢,佩曼莫

4

1 回答 1

0

使用类的UrlDecodeUrlEncodeUnicode方法HttpUtility在这里阅读更多。

于 2013-09-04T04:57:21.117 回答