Setting two fields with the same JsonProperty

1

I would like to set two fields with the same JsonProperty value. If I try to have both of the fields with the same JsonEntity value I will get an error that I can't have two fields with the same JsonProperty.

public class Entity
{
    [JsonProperty("role_code")]
    public String JobDescriptionId
    {
        get
        {
            return JobDescriptionId;
        }
        set 
        {
            JobDescriptionId = value;
            GroupCode = value;
        }
    }

    public String GroupCode { get; set; }
}

Serialize it like this:

JsonConvert.DeserializeObject<JsonEntitys>("{ \"role_code\": \"test\" }");

But I get

(0xc0000005) 'Access violation'
c#
asp.net-core
asked on Stack Overflow Nov 18, 2019 by SwagiWagi

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0