I'm trying to get the child of a JToken. I would drill down via name but it's kind of random(ish) numbers and I wondered if there is a way to just select the child?
My current code is:
var jobs = new Collection<Job>();
JObject jObject = JObject.Parse(json);
JToken jCharacter = jObject["Character"];
var jClassJobs = jCharacter["ClassJobs"].Children();
foreach (JToken jClassJob in jClassJobs)
{
Int16 cId = (Int16)jClassJob.Value<short>("ClassID");
Int16 cLevel = (Int16)jClassJob.Value<Int16>("Level");
jobs.Add(new Job
{
Id = cId,
Level = cLevel
});
}
return jobs;
The json I'm trying to get my Id and Level from looks like this but the 10_10 in this example would be 10_20 in a different one, and then even 10_30 later on. It's got a pattern but trying to do it neatly:
{"10_10": {
"ClassID": 10,
"ExpLevel": 26675,
"ExpLevelMax": 324000,
"ExpLevelTogo": 297325,
"IsSpecialised": false,
"JobID": 10,
"Level": 40
}}
Any suggestions would be appreciated, I've been trying for hours.