Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mark a property as non serializable for json?

Tags:

c#

asp.net-mvc

As the title says, I want to mark a property as non serializable by the JavascriptSerializer. How can achive that ? Thanks in advance.

like image 632
Zoliqa Avatar asked Feb 24 '11 10:02

Zoliqa


People also ask

How can you prevent a property from being serialized?

You can prevent member variables from being serialized by marking them with the NonSerialized attribute as follows. If possible, make an object that could contain security-sensitive data nonserializable. If the object must be serialized, apply the NonSerialized attribute to specific fields that store sensitive data.

Which of the following attributes are required to ignore properties for JSON serializer?

To ignore individual properties, use the [JsonIgnore] attribute.

Which of the following attribute should be used to indicate the property must not be serialized while using JSON serializer?

Apply a [JsonIgnore] attribute to the property that you do not want to be serialized.


1 Answers

I think you just want to apply the ScriptIgnoreAttribute:

[ScriptIgnore]
public string IgnoreThis { get; set; }
like image 51
Jon Skeet Avatar answered Oct 12 '22 20:10

Jon Skeet