how can i make nest dictionary bit short or easy to handle?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By potatobanana

how can i make nest dictionary bit short or easy to handle?
or there other way to make something similar without using nest dict?

var testSlot  = {
  "InvSlot1": {
    "itemID": "ironSword",
    "stack": 1,
    "itemData": {
      "name": "Iron Sword",
      "category": "One Hand Weapon",
      "itemType": "equipment",
      "grade": "common",
      "rank": 1,
      "stackSize": 1,
      "stackable": false,
      "invSfx": "armor",
      "equipmentSlot": "right_hand",
      "description": "just normal sword make it out from iron",
      "def": null,
      "mDef": null,
      "maxHp": null,
      "maxMp": null,
      "maxSta": null,
      "matk": null,
      "minAtk": 5,
      "maxAtk": 10,
      "knockback": null,
      "mine": null,
      "cutDown": null,
      "crit": null,
      "mSpd": null,
      "critCha": null,
      "cdR": null,
      "STR": null,
      "CON": null,
      "DEX": null,
      "WIS": null,
      "INT": null,
      "LUK": null,
	  "modSkill" : {
			"itemID":"heal",
			"stack":1,
			"itemData" :{
				"name"       : "Heal",
				"category"   : "active",
				"itemType"   : "skill",
				"skillType"  : "singleTarget",
				"target"     : "self",
				"level"      : 1,
				"grade"      : "Rare",
				"cd"         : 2,
				"bonus1"     : null,
				"bonus2"     : null
				}
		}
    }
  }
}
:bust_in_silhouette: Reply From: Legorel

Try using classes instead of dictionaries. From your code I would create these classes:
InventorySlot, ItemData, ModSkill
They would have variables to replace key-value pairs and you could even add useful methods

Also, for these kind of data class. It’s good to extends from Resource, and

export var inventory_slot: InventorySlot

According to [3.x] Allow exporting custom resources from/to any scripting language (GDScript, VisualScript, C#, NativeScript, PluginScript) by willnationsdev · Pull Request #44879 · godotengine/godot · GitHub, in Godot 3.4, you can export custom resource in the editor. This way OP can easily create an item in the editor and save it to .tres.

MintSoda | 2021-09-02 22:10