I have is a list of properties, like public string RefID { get; set; } public bool myNiceProp { get; set; } and so on. I receive a string, and, some of those are in, for example "myNiceProp" = "1". First part of the problem, is to identify that I have the property "myNiceProp" and, if not, throw error, if yes, populate the value (and here is the second part of the problem, I must try to cast or somehow make sure the type is correct before I set the value to my property).I don't know which/how many key/value pairs are in the string.
Example:
public class InternationalSpaceStation
{
public Location position { get; set; }
public string missionName { get; set; }
public int missionNumber { get; set; }
}
public class Location
{
string coordinate { get; } = "Equatorial";
string inclination { get; set; }
string rightAscension { get; set; }
}
and my string looks like this:
{ "_report": { "ISS": { "inclination": "51.6430"
"rightAscension": "53.5336" }, "status": { "missionName": "Aquarius" } }, "ccId": "42NM", }
So, I don't really care for the "_report" because has no value, but I do wnt to find all nested pairs of keys and values and assign their value to my properties, if I have them (if not, to throw error). I don't care if i have more properties - but, less, is a problem.
I thought to try with String.Split but I also have the problem of the type, so I must try to convert the string's value type to mine (in string, all values are in quotes).
Any help would be immensely appreciated..