runtime icon indicating copy to clipboard operation
runtime copied to clipboard

JsonIgnore in record declaration

Open Julien-Marpault opened this issue 4 years ago • 4 comments

If we could use JsonIgnoreAttribute like this it could be very useful. image

Thanks

Julien-Marpault avatar Dec 17 '21 17:12 Julien-Marpault

I think this issue is already tracked, (can't find the exact issue though)

For the time being, you could use the following workaround to add an attribute to a property in a record

public record CustomerUser(Guid UserId, [property:JsonIgnore] Guid CustomerId, Guid RoleId);

MariovanZeist avatar Dec 17 '21 18:12 MariovanZeist

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost avatar Dec 17 '21 18:12 ghost

Tagging subscribers to this area: @dotnet/area-system-text-json See info in area-owners.md if you want to be subscribed.

Issue Details

If we could use JsonIgnoreAttribute like this it could be very useful. image

Thanks

Author: Julien-Marpault
Assignees: -
Labels:

question, area-System.Text.Json, untriaged

Milestone: -

ghost avatar Dec 18 '21 06:12 ghost

The exact same issue: #49212, and similar: #60690 I'm going to close this issue as the solution is straight. However, I think it's worth some hint by the IDE.

huoyaoyuan avatar Dec 20 '21 09:12 huoyaoyuan