Getting a path of a resource file

Godot Version

v4.5.1.stable.steam [f62fdbde1]

Question

I’m trying to make a strategy game and currently stuck on saving player’s unit list to the disc. unit data is stored in Resource, so ideally I’d want to just save list of paths to the Resources, problem is I don’t know ahead of time which Resources they are.
So, I want to cycle over an array of Resources and get an array of their paths so that I can just load them when loading the game. Is there a way to get a Resource’s file path?

Resource::resource_path
Although the approach you described sounds a bit strange. Why not just reference the resources from another resource object and let the engine resolve the dependencies.

Thank you! I need the path because my player save setup is:

{
#... various player data
units:[
{"base_unit_data":"path//I/wanted","experience":10,"wounded":false #etc
},{
#same unist strcuture
}
]

}