質問

I would like to be able to say, this attribute has to be first in the serialized json. Our json structure includes href to resource, and we would like to have it be a 1st attribute in json. Is it possible?

役に立ちましたか?

解決

Use the DataContract and DataMember attributes. They will work for both JSON and XML. The JSON properties might not work for all SerivceStack versions but I've confrimed it works with v4.

[System.Runtime.Serialization.DataContract]
public class Team : IReturn<Team>
{
    [System.Runtime.Serialization.DataMember(Order = 3)]
    public int Id { get; set; }

    [System.Runtime.Serialization.DataMember(Order = 2)]
    public string Name { get; set; }

    [System.Runtime.Serialization.DataMember(Order = 1)]
    public DateTime CreatedDate { get; set; }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top