I'm saving JSON objects into the database, sometimes it grows very large (I have an object of length 205,797 characters) I want to eliminate the size as possible as I can. these objects have a lot of GUID fields, all I don't need, It may help eliminating the size if there is a way to ignore any GUID type from serializing.
This is my code, I pass an object of any model type in my application:
public static string GetEntityAsJson(object entity)
{
var json = JsonConvert.SerializeObject(entity, Formatting.None, new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
return json;
}
EDIT
I don't want to use JsonIgnore
attribute, as I will have to add it to so many classes each has a lot of GUID properties,
I'm looking for something straight forward like:
IgnoreDataType = DataTypes.GUID