忽略通过JsonPropertyAttribute设置的字母的大小写

时间:2012-06-10 16:09:07

标签: c# windows-phone-7 json.net

我有一个有三个简单属性的类:

public class NewCard {
    [JsonProperty( "name" )]
    public string Name { get; set; }

    [JsonProperty( "desc" )]
    public string Desc { get; set; }

    [JsonProperty( "idList" )]
    public string IdList { get; set; }
}

我期待这样的结果:

{"name":"A name","desc":"","idList":"listId"}

不幸的是,我得到的结果如下:

{"Name":"A name","Desc":"","IdList":"listId"}

远程服务拒绝json,所以我真的需要降低它们。 JSON.NET版本:使用NuGET下载4.5.6。

1 个答案:

答案 0 :(得分:1)

当我序列化为

时,我得到了你期望的结果
var json = JsonConvert.SerializeObject(new NewCard() {Name="A Name",Desc="A Desc",IdList="ids" });