web api instance method
RTCIceCandidate: toJSON() method
The RTCIceCandidate method toJSON() converts the RTCIceCandidate on which it’s called into JSON.
A stringified version of the object can then be obtained by calling stringify() on the returned object.
Syntax
toJSON()
Parameters
None.
Return value
A JSON object with the following properties, which have been set to the corresponding values in the RTCIceCandidate object:
-
candidateOptional- : A string describing the network connectivity information for the candidate.
Additional information can be found in
candidate.
- : A string describing the network connectivity information for the candidate.
Additional information can be found in
-
sdpMidOptional- : A string containing the identification tag of the media stream with which the candidate is associated, or
nullif there is no associated media stream. Additional information can be found insdpMid.
- : A string containing the identification tag of the media stream with which the candidate is associated, or
-
sdpMLineIndexOptional- : A number property containing the zero-based index of the m-line with which the candidate is associated, within the SDP of the media description, or
nullif no such associated exists. Additional information can be found insdpMLineIndex.
- : A number property containing the zero-based index of the m-line with which the candidate is associated, within the SDP of the media description, or
-
usernameFragmentOptional- : A string containing the username fragment (usually referred to in shorthand as “ufrag” or “ice-ufrag”).
This fragment, along with the ICE password (“ice-pwd”), uniquely identifies a single ongoing ICE interaction (including for any communication with the STUN server).
Additional information can be found in
usernameFragment.
- : A string containing the username fragment (usually referred to in shorthand as “ufrag” or “ice-ufrag”).
This fragment, along with the ICE password (“ice-pwd”), uniquely identifies a single ongoing ICE interaction (including for any communication with the STUN server).
Additional information can be found in
[!NOTE] The returned JSON object has the same form/properties as the
candidateInfoobject that can optionally be passed to theRTCIceCandidate()constructor to configure the candidate.
Examples
This simple example obtains a JSON string representing an RTCIceCandidate found in the variable candidate.
let jsonString = candidate.toJSON().stringify();
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.