c# - JSON .NET serialization of generic collections -


it feels have simple problem. i've got data class couple of generic collections , i'd have them serialized well. reading internet here's 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 can see there's type identifier in each of objective/reward object. there no values.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -