Skip to content

Commit ad07864

Browse files
author
Chris Santero
committed
do not serialize primitive type properties that have a JsonIgnore attribute
1 parent 3955509 commit ad07864

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

JSONAPI/Json/JsonApiFormatter.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ protected void Serialize(object value, Stream writeStream, JsonWriter writer, Js
147147

148148
if (this.CanWriteTypeAsPrimitive(prop.PropertyType))
149149
{
150+
if (prop.GetCustomAttributes().Any(attr => attr is JsonIgnoreAttribute))
151+
continue;
152+
150153
// numbers, strings, dates...
151154
writer.WritePropertyName(FormatPropertyName(prop.Name));
152155
serializer.Serialize(writer, prop.GetValue(value, null));

0 commit comments

Comments
 (0)