GameObject from foreach loop dosn't have transform?,

I’m trying to make the following code work:

public void saveData()
    {
        if (mainHand)
        {
            GameObject[] saveObjects = GameObject.FindGameObjectsWithTag("deletableobject");
            SandboxObject sandboxObject = new SandboxObject();
            foreach (GameObject obj in saveObjects)
            {
                Transform objTransform = obj.transform;
                deleteOnHit objData = obj.GetComponent<deleteOnHit>();
                sandboxObject.pos.Add(objTransform.position);
                sandboxObject.rot.Add(objTransform.rotation.eulerAngles);
                sandboxObject.scale.Add(objTransform.localScale);
                sandboxObject.matNum.Add(objData.matNum);
                sandboxObject.matFileNum.Add(objData.matFileNum);
                sandboxObject.meshNum.Add(objData.meshNum);
            }
            string saveJson = JsonUtility.ToJson(sandboxObject);

            File.WriteAllText(Application.dataPath + "saveFile", saveJson);

            Debug.Log("saved as: " + saveJson);
        }
    }

This code is supposed to save all object with tag of “deletableobject” into a single json file, but on
line 11, it throws me a NullReferenceExeption.

I have 3 object with tag"deletableobject" on scene, and they all have script deleteOnHit.

What’s causing this error?
Please let me know if you do.

Thank you!

UPDATE:
I realized that this problem happens with a for loop as well:

public void saveData()
    {
        if (mainHand)
        {
            GameObject[] saveObjects = GameObject.FindGameObjectsWithTag("deletableobject");
            SandboxObject sandboxObject = new SandboxObject();
            for (int i = 0; i < saveObjects.Length; i++)
            {
                Transform objTransform = saveObjects*.transform;*

deleteOnHit objData = saveObjects*.GetComponent();*
sandboxObject.pos.Add(objTransform.position);
sandboxObject.rot.Add(objTransform.rotation.eulerAngles);
sandboxObject.scale.Add(objTransform.localScale);
sandboxObject.matNum.Add(objData.matNum);
sandboxObject.matFileNum.Add(objData.matFileNum);
sandboxObject.meshNum.Add(objData.meshNum);
}
string saveJson = JsonUtility.ToJson(sandboxObject);

File.WriteAllText(Application.dataPath + “saveFile”, saveJson);

Debug.Log("saved as: " + saveJson);
}
}

Nvm I just found out that it was the problem in the “SandboxObject” class.

Used to be:

private class SandboxObject
    {
        public List<Vector3> pos;
        public List<Vector3> rot;
        public List<Vector3> scale;
        public List<int> matNum;
        public List<int> matFileNum;
        public List<int> meshNum;
    }

Fixed:

private class SandboxObject
    {
        public List<Vector3> pos = new List<Vector3>();
        public List<Vector3> rot = new List<Vector3>();
        public List<Vector3> scale = new List<Vector3>();
        public List<int> matNum = new List<int>();
        public List<int> matFileNum = new List<int>();
        public List<int> meshNum = new List<int>();
    }