0

I have a json response that may or may not contain a value called t_ID. Currently I have the following property defined in a class:

[JsonProperty("t_ID")]
public string TID { get; set; }

If it does not exist I don't want to do anything with it - if it exists in the JSON response I want to deserialize it into the class.

How can this be done?

5
  • Define "I don't want to do anything with it"? Commented Aug 22, 2018 at 12:02
  • what happens if u name TID to t_ID? Commented Aug 22, 2018 at 12:03
  • @CodeCaster i mean if t_ID doest not exist - it does not exist (I cant deserialize something that does not exist). Commented Aug 22, 2018 at 12:10
  • That doesn't answer my question. If the field is not present in the JSON, the deserialized object will contain the default value for that property. Commented Aug 22, 2018 at 12:25
  • The linked solution worked. Thanks. What is the default value ? Commented Aug 22, 2018 at 12:28

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.