The arrays of Float64 data in sensor_msgs/JointState are represented by a std::vector<double> when using roscpp. You should thus be able to get the length of the vector by calling YOUR_MSG.velocity.size().