RTCSessionDescription: toJSON() 方法

Baseline 已廣泛支援

此功能已成熟,可跨多種裝置和瀏覽器版本使用。自 2017 年 9 月以來,它已在瀏覽器中提供。

RTCSessionDescription.toJSON() 方法會生成一個物件的 JSON 描述。生成的 JSON 中包含了 typesdp 這兩個屬性。

語法

js
toJSON()

引數

無。

返回值

一個包含以下屬性的 JSON 物件

type

以下值之一:"offer""answer""pranswer"null

SDP

null 或與 RTCSessionDescription.sdp 屬性對應的 SDP 訊息字串。

示例

js
// sd is a RTCSessionDescriptor

alert(JSON.stringify(sd)); // This call the toJSON() method behind the scene.

規範

規範
WebRTC:瀏覽器中的即時通訊
# dom-rtcsessiondescription-tojson

瀏覽器相容性

另見