unity – Equipped weapon does not appear in JSON data

Whenever your equipped weapon is not the last one in the array, the one immediately after it sets selectedweapon = -1 at the end. What you want to do is scan through the array until you find the equipped weapon, then stop searching.

Replace your for loop with something like this:

selectedweapon = -1;
for (int i = 0; i < weaponItemSOs.Length; i++)
{
    if (weaponItemSOs(i).isEquiped)
    {
        selectedweapon = i;
        break;
    }
}

Or as a one-liner:

selectedWeapon = System.Array.FindIndex(weaponItemSOs, weapon => weapon.isEquipped);