c# - NewtonSoft JsonConvert deserialize on dynamic object type -
I have an abstract object in which there are many children: radioist, checktimes, etc.
Each item stores its properties in a serialized JSON string property.
I am trying to create a stable class that can take in an item, can instantaneously trigger a new item from the JSON string and return it.
Now I have the code that looks like this:
Public Stuffed Item GetFreshItem (item dirty item) {string itemProperties = dirty item. Preliminary ITM settings jQuery; If (Dirty ITM is Radiatlum) {Return Jason Convert. Directoryal Object & lt; Radioiteum & gt; (MadProperties); } If (Dirty ITE checklist) {Return Jason Convert. Directoryal Object & lt; Checkout & gt; (Item properties); } Return tap; } If there is no long list of (x type) and there is no way to use more dynamic single return statement on that type of basis?
I was thinking that something like this (which does not work)
JsonConvert.DeserializeObject & lt; typeOf (dirtyItem) & gt; (ItemProperties);
I think that you are looking for deserialize method. String item properties = dirty item. Initial Items Settings JSON; Return to Jason (Item) Directoryal Object (ITIP Properties, Dirty Items. GateType ());
Comments
Post a Comment