I am trying to pull records from server via webservice in and in my model I have a parameter named public String mId {get;set;}
and my JSON structure is as follows
{ "name":"Jhon", "mId":"", "address":"55 jump street" }
Now when mId
is blank i want to generate a new GUID
for this field while deserializing json using Newton JSON
as [DefaultValue("")]
is accepting only constant value i can not use Guid.NewGuid()
over there
That is not what DefaultValue
is used for. To add a default value:
string mId { get; set; } = Guid.NewGuid()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.