How to exclude property from Json Serialization

Jak
Jak
Member
352 Points
151 Posts

Hi,

I am using Newtonsoft to serialize object. I wan to ignore some property but unable to do this.

var json=JsonConvert.SerializeObject(playerItem);

In the class:

[Serializable]
public class player
{
[System.Web.Script.Serialization.ScriptIgnore]
public string playerId { get; set; }
}

Please help

Views: 8317
Total Answered: 1
Total Marked As Answer: 0
Posted On: 04-Mar-2016 08:22

Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul M...
Moderator
1170 Points
210 Posts
     

Hi Jak,

You need to use [Newtonsoft.Json.JsonIgnore] attribute as

[Serializable]
public class BaseBallPlayerStats
{
    [Newtonsoft.Json.JsonIgnore]
    public string playerId { get; set; }
}
Posted On: 04-Mar-2016 08:37
banner

Blog

Active User (2)

 Log In to Chat