The RTCIceCandidate method toJSON() converts the RTCIceCandidate on which it's called into JSON.
toJSON()
RTCIceCandidate
MDN Reference