How can I not serialize some attributes in RESTful (C # + WCF + JSON) calls?

3

In the example below, how do I not serialize an attribute.

I think I'm looking for the equivalent of the java syntax:

For classes: @JsonIgnoreProperties (ignoreUnknown = true); For attributes: @JsonIgnore for attribute.

public class SomeFakeClass
{    
    public int ID { get; set; }

    public string Text { get; set; }

    public decimal Value { get; set; }
}

How to not serialize 1: class, 2: a particular attribute.

Thank you!

    
asked by anonymous 16.09.2014 / 17:01

1 answer

3

Try using the IgnoreDataMemberAttribute on the property.

Example with the ID property of your class:

public class SomeFakeClass
{
    [IgnoreDataMember]
    public int ID { get; set; }

    public string Text { get; set; }

    public decimal Value { get; set; }
}
    
16.09.2014 / 19:54