0

I need to inject the specific property value to object that is being deserialize using JsonConvert.DeserializeObject method.

for example I have a class

public class Employee
{
   public int EmployeeID {get; set;}
   public string Name {get; set;}
   public int OrgnizationID {get; set;}
}

Json

[
    {
      "employeeID": 1,
      "name": "Neeraj"
    },
    {
      "employeeID": 2,
      "name": "Sam"
    },
    {
      "employeeID": 3,
      "name": "Jonson"
    } 
]

above json string converting to list of employee. Here I am looking a way to set the OrgnizationID with some value for full of list. I know I can set it after conversion, but god to have if I can set it along with conversion.

var employees  = JsonConvert.DeserializeObject<List<Employee>>(jsonData);

in above line of code I am also passing the JsonSerializerSettings for some other purpose that not defined here just to keep question simple.

Neeraj Kumar Gupta
  • 2,157
  • 7
  • 30
  • 58

0 Answers0