Hi @PrathameshShende-2581 ,
To ignore individual properties, you can use the [JsonIgnore] attribute,like this:
Model:
public class Emp
{
public int ID { get; set; }
[JsonIgnore]
public string Name { get; set; }
}
c#
Emp emp = new Emp()
{
ID = 1,
Name = "Test"
};
var json = JsonSerializer.Serialize(emp);
Console.WriteLine(json);
Result:
For more ignored properties of System.Text.Json, you can refer to the official documentation for viewing.
How to ignore properties with System.Text.Json
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best Regards,
ChaoDeng