Search code examples
c#jsonjson.netasp.net-core-webapi

how to stop ignoring jObject properties when we call API?


I'm calling API using postman, I'm sending dynamic properties using JObject as given below

I'm sending class data to API using JSON but which is ignoring the values of duplicate data

     public class Details
        { 
            public List<JObject> Mappings { get; set; } 

             // adding properties to jobject abd mappings     

            [JsonExtensionData]
            public IDictionary<string, JToken> AdditionalProperties { get; set; }

         }

I'm using below JSON in postman

    {      
      "source": {
            "details": "Sample Customer",
            "compoet": "Sample Site",
            "Name": "Sample Software",
            "Version": "1.0.1",
            "Creator": "Sample Company"
        },
      "Mappings":[
      {
        "data": Test.Name1",
        "data": Test.Name23",    
        "newprop":"Account1",
      }
    {
        "data": "Test.Name2",    
        "newprop":"Account2",
      }
    ]
    }

when I pass duplicate key API is taking second value "data": Test.Name23" I want API should take both values from mapping can anyone help?


Solution

  • it's better don't do that, and this is my reason

    you can pass "data" value as an array