[webrtc-pc] WebIDL serializer has been deprecated in favor of toJSON operation

tobie has just created a new issue for https://github.com/w3c/webrtc-pc:

== WebIDL serializer has been deprecated in favor of toJSON operation ==
Hi!

We recently [deprecated WebIDL serializers][0]. You can now directly specify [toJSON operations][1] instead, which you previously weren't allowed to do.

To deal with common cases, we added a new [\[Default\] extended attribute][2] which triggers the [default toJSON operation][3] that behaves similarly to how `serializers={attributes}` or `serializers={attributes, inherit}` used to. That is, it serializes all attributes that are of a [JSON type][4] into a vanilla JSON object.

It seems the following interfaces in this spec are impacted by this change:

- [ ] [`RTCSessionDescription`](http://w3c.github.io/webrtc-pc/#idl-def-rtcsessiondescription)
- [ ] [`RTCIceCandidate`](http://w3c.github.io/webrtc-pc/#idl-def-rtcicecandidate)

`RTCSessionDescription` seems to be good candidate for the [default toJSON operation][3]. The below should be all you need for it:

```webidl
[Constructor(RTCSessionDescriptionInit descriptionInitDict)]
interface RTCSessionDescription {
    readonly attribute RTCSdpType type;
    readonly attribute DOMString  sdp;
    [Default] object toJSON();
};
```

On the other hand, you'll need to define a custom `toJSON` operation for `RTCIceCandidate`. There's [an example][5] of a custom `toJSON` operation in the WebIDL spec to get you started. 

I'm sorry for the inconvenience this causes, but our hope is that this ultimately makes things a lot simpler and clearer for everybody.

Please feel free to reach out if you have any questions.

Thanks!

[0]: https://github.com/heycam/webidl/commit/a505f33
[1]: https://heycam.github.io/webidl/#idl-tojson-operation
[2]: https://heycam.github.io/webidl/#Default
[3]: https://heycam.github.io/webidl/#es-default-tojson
[4]: https://heycam.github.io/webidl/#dfn-json-types
[5]: https://heycam.github.io/webidl/#tojson-example

Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/1419 using your GitHub account

Received on Thursday, 22 June 2017 11:57:43 UTC