The Jiangmen Underground Neutrino Observatory (JUNO) features a 20 kt multi-purpose underground liquid scintillator sphere as its main detector. Some of JUNO's features make it an excellent location for 8B solar neutrino measurements, such as its low-energy threshold, high energy resolution compared with water Cherenkov detectors, and much larger target mass compared with previous liquid scintillator detectors. In this paper, we present a comprehensive assessment of JUNO's potential for detecting 8B solar neutrinos via the neutrino-electron elastic scattering process. A reduced 2 MeV threshold for the recoil electron energy is found to be achievable, assuming that the intrinsic radioactive background 238U and 232Th in the liquid scintillator can be controlled to 10-17g/g. With ten years of data acquisition, approximately 60,000 signal and 30,000 background events are expected. This large sample will enable an examination of the distortion of the recoil electron spectrum that is dominated by the neutrino flavor transformation in the dense solar matter, which will shed new light on the inconsistency between the measured electron spectra and the predictions of the standard three-flavor neutrino oscillation framework. If Δm221= 4.8 × 10-5(7.5 × 10-5) eV, JUNO can provide evidence of neutrino oscillation in the Earth at approximately the 3σ (2σ) level by measuring the non-zero signal rate variation with respect to the solar zenith angle. Moreover, JUNO can simultaneously measure Δm221using 8B solar neutrinos to a precision of 20% or better, depending on the central value, and to sub-percent precision using reactor antineutrinos. A comparison of these two measurements from the same detector will help understand the current mild inconsistency between the value of Δm221reported by solar neutrino experiments and the KamLAND experiment.