John Riker

John Riker

  • NA
  • 85
  • 15.8k

Can you clear objects while code still running?

Nov 4 2020 4:11 PM
I have some JSON that I deserialize by doing like:
 
Rootobject rootObject = JsonConvert.DeserializeObject(rawJSON);
 
That gets put into things like:
  1. public class Rootobject  
  2. {  
  3. public Result result { getset; }  
  4. public bool success { getset; }  
  5. }  
  6. public class Result  
  7. {  
  8. public string title { getset; }  
  9. public Datum[] data { getset; }  
  10. public int total { getset; }  
  11. }  
  12. public class Datum  
  13. {  
  14. public string type { getset; }  
  15. public string title { getset; }  
  16. public string series_title { getset; }  
  17. public string label { getset; }  
  18. public string content_id { getset; }  
  19. public string airdate { getset; }  
  20. public long airdate_ts { getset; }  
  21. public DateTime airdate_iso { getset; }  
  22. public string expiredate_raw { getset; }  
Everything working great. That said, I want to now run
 
Rootobject rootObject = JsonConvert.DeserializeObject(rawJSON);
 
again with a different set of JSON data. Basically a different feed but the exact same layout. Will all the above class objects still have the old data in it and when I loop thru that data will just be appended to it? If so is there a way to clear all values before looping thru the second process without creating two programs that run separately?

Answers (2)