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

浏览器兼容性

另见