How to get some unique identifier for GameObjects?

I need to resolve the following issue:
I was saving in a Json the IDs of some GameObjects, using the GetInstanceID () method; then I could load them using a custom function. But when making the final tests, when changing the scene or doing the build, I was surprised that the IDs of the GameObjects changed, therefore the load with the custom function was wrong since it did not find the IDs previously saved.
What is needed is to obtain some type of ID, code or whatever from a GameObject to identify it, and that this ID, code or whatever never changes, is that possible?
Additional note:
I tried to use generation with GUIDs, but where would I store that ID? I have more than 1000 GameObjects.
I’m thinking of generating the IDs manually, attaching a script to each GameObject at runtime, this would work as long as no GameObjects are added, removed, disabled.

If you want the identifiers to be consistent, then it would be best to generate and serialize them in the Editor. The easiest way of doing so would be to have the GUID as a serializable field on a script;

using System;

public class UniqueID : MonoBehaviour
{
    //I would suggest adding some kind of ReadOnly attribute/inspector to this such that you can see it in the inspector but can't edit it directly
    [SerializeField] private string m_ID = Guid.NewGuid().ToString();

    //If you need to access the ID, use this
    public string ID => m_ID;

    //This allows you to re-generate the GUID for this object by clicking the 'Generate New ID' button in the context menu dropdown for this script
    [ContextMenu("Generate new ID")]
    private void RegenerateGUID () => m_ID = Guid.NewGuid().ToString();
}

Thanks, this generates unique IDs, but the problem is that, every time you give Play in Unity’s Editor, new IDs are generated, I need it to be the same always. @Namey5