Total beginner here.
I have a project where I need to deserialize a JSON file into C#. I've gotten most of it down fairly well. Unfortunately, there's one part of the JSON file that doesn't want to come through—probably due to the fact that the object name is not uniform and I can't seem to find a way to get the deserializer to recognize it.
{
"version": "36",
"releaseDate": "20220223",
"releaseType": "Chem",
"calibrations": {
# OTHER OBJECTS...
"chemCalibrations": {
"Cal-He-Varying-hyphenated-name1": {
"Version": "1.0",
"Element": "He",
"Nucleons": 4,
"Label": 1,
"lighting": 1,
"scope": "A",
# OTHER KEY-VALUE PAIRS AND SUB-ARRAYS...
}
"Cal-Li-Varying-hyphenated-name2" : {
# THE SAME KEY-VALUE PAIR TYPES AS ABOVE
}
...
"Cal-Yy-Varying-hyphenated-nameX" : {
# THE SAME KEY-VALUE PAIR TYPES AS ABOVE
}
}
}
So, in the JSON string above, there's a recurring object within the "chemCalibrations" object that has a varying name starting with "Cal", a hyphen, then an elemental or chemical prefix, then a bunch of other hyphenated stuff. The hyphenated stuff varies, as does the elemental/chemical prefixes. Also the number of those objects varies as well.
I've set up a namespace in C# with a bunch of public classes for these objects, but the generic name I've given to the class for the "Cal-..." objects isn't working when deserializing.
public class ChemCals
{
public string Version { get; set; }
public string Element { get; set; }
public int Nucleons { get; set; }
public int Label { get; set; }
public int Lighting { get; set; }
...
}
public class ChemCalibrations
{
public ChemCals chemCals { get; set; }
}
For a newbie, it's a head-scratcher. I'm sure there's an easy solution here, but I'm stuck. How do I ensure that the JSON deserializer populates the "ChemCals" class here from an indefinite number of varying object names? Thank you.