JSON Deserialize with empty field c# -


i'm testing api calls in c# , getting following json response:

{   "message": "the request invalid. model validation failed.",   "validationerrors": {     "": {       "reasons": [         "a customer must added order before can placed."       ]     }   } } 

i want map response class json deserializer , have no control on how response formed. how handle empty field in validationerrors can still access reasons list in object?

note: when ran through json2csharp gave not useful mapping field within validationerrors class.

public __invalid_type__ __invalid_name__ {get;set;} 

deserialize dictionary<string, validationerror>:

public class validationerror {     public list<string> reasons { get; set; } }  public class rootobject {     public string message { get; set; }     public dictionary<string, validationerror> validationerrors { get; set; } } 

this work out-of-the-box , . if using datacontractjsonserializer (tagged ) need set datacontractjsonserializer.usesimpledictionaryformat = true (.net 4.5 , above only).


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -