I’m trying to save player’s inventory as a Json data, but I’m having a problem. I have a class Sword which extends abstract class Weapon which extends another abstract class Item. This is what Json file looks like with Sword and Armor object in it: `
[
{
"category": {
"type": "Weapon",
"subtype": "Sword"
},
"id": 0,
"value": 1,
"name": "Wooden Sword",
"description": "Sword made out of wood",
"slug": "wooden_sword",
"stats": {
"wear": 100,
"damage": 5
}
},
{
"category": {
"type": "Armor",
"subtype": "Helmet"
},
"id": 1337,
"value": 1,
"name": "Steel Helmet",
"description": "Whatever...",
"slug": "steel_helmet",
"stats": {
"wear": 100,
"defence": 5,
"vitality": 3,
"dexterity": -1
}
}
]
How can I possibly parse these objects into their respective C# objects?