c# - How can I deserialize both responses using the same class? -


I am currently receiving data from API which comes like this:

  {"Message": [... somedata ...], "Timestamp": 123456, "Request": 1}  

How can I easily remove them:

  public class data {[Jasonproperty ("Message")] Public list & lt; ... & gt; Message {receive; Set; } [Jasonproperty ("Timestamp")] Public Int Timestamp {Received; Set; } [Jasonproperty ("Request")] Public IT Request (Left) {Received; Set; }}  

However, the same API can return data with properties such as a few names in this way:

  {"m": [.. How can I use the same class to waste both formats? Or is it not possible and I need every class of it?   

You can do something like this:

  public class data { [Jasonprotterty ("Message")] Public List & lt; ... & gt; Message {receive; Set; } [Jasonprotterty ("m")] Public listing & lt; ... & gt; M_list {Get {Return Message; } Set {messages = value; }} [Jasonproperty ("Timestamp")] Public Int Timestamp {Received; Set; } ... [JsonProperty ("Request")] {Received Public Ent Requests; Set; } ...}  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -