Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
// following is the class
class demo {
     public List<string> NotifyEmail { get; set; };
     public List<string> NotifyPhone { get; set; }
     public List<string> Inspectors { get; set; }
}

I want to send the following data which means I want to send "[]" value:
C#
 {
 "Email": [],
 "Phone": [],
 "inspectors": []
}

But if there is no value null passing:
C#
{
 "Email": null,
 "Phone": null,
"inspectors": null
}

I want to send "[]" instead of null:

Can anyone help me please!

What I have tried:

I tried some code, but still null is going.
Posted
Updated 4-Oct-23 2:58am
v2

Consider changing the default value on the assessor. Then when its passed empty, you get the same result on the first set.

C#
class demo {
     public List<string> NotifyEmail { get; set; } = new List<string>();
     public List<string> NotifyPhone { get; set; } = new List<string>();
     public List<string> Inspectors { get; set; } = new List<string>();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900