It feels like I have a simple problem. I've got a data class with a couple of generic collections and I'd like to have them serialized as well. Reading the Internet here's what I'm doing:
The class:
public class QuestModel
{
public string NameTag { get; set; }
public string DescTag { get; set; }
public int QuestLevel { get; set; }
public Queue<QuestObjectiveBase> Objectives { get; set; }
public List<QuestRewardBase> Rewards { get; set; }
public bool Completed { get; set; }
public bool TrackingProgress { get; set; }
public QuestModel()
{
Objectives = new Queue<QuestObjectiveBase>();
Rewards = new List<QuestRewardBase>();
TrackingProgress = false;
Completed = false;
}
}
The code:
var json = JsonConvert.SerializeObject(sideQuests[0].Model, Formatting.Indented, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto
});
The output:
{
"NameTag": "QUESTS_TEST_NAME",
"DescTag": "QUESTS_TEST_DESC",
"QuestLevel": 10,
"Objectives": [
{
"$type": "Warlocks.Gameplay.Quests.Impl.Objectives.KillEnemiesQuestObjective, Assembly-CSharp"
}
],
"Rewards": [
{
"$type": "Warlocks.Gameplay.Quests.Impl.Rewards.GoldQuestReward, Assembly-CSharp"
}
],
"Completed": false,
"TrackingProgress": true
}
As you can see there's only a type identifier in each of the Objective/Reward object. But there are no values.