Intent to Prototype and Ship: Response.json()

393 views
Skip to first unread message

Adam Rice

unread,
May 30, 2022, 10:08:17 PMMay 30
to blink-dev

Contact emails

ri...@chromium.orgyhi...@chromium.org

Explainer

https://docs.google.com/document/d/1dTycWmyxLZNGTBW93fvtf1IQahx-vNwgu94yT1x9K50/edit

Specification

https://fetch.spec.whatwg.org/#ref-for-dom-response-json

Summary

Improves ergonomics for creating JSON Response objects. The Response constructor allows for creating the body of the response from many types, however it is not possible to directly create a JSON object. The Response.json() static method fills this gap. It returns a Response object with a body consisting the first argument serialized as JSON. The second argument is a ResponseInit option bag as with the Response constructor.



Blink component

Blink>Network>FetchAPI

Motivation

Creating a Response object with a body of a JSON object has been harder than the other types supported by Fetch. This change improves the ergonomics of creating a JSON response.



Initial public proposal

https://github.com/whatwg/fetch/issues/1389

TAG review

https://github.com/w3ctag/design-reviews/issues/741

TAG review status

Pending

Risks



Interoperability and Compatibility

Interoperability risk is low as Deno and Node have already implemented the feature, and it is a simple addition to the API. We know of no compatibility risk. It could happen if someone is using a polyfill with an incompatible API, but that is unlikely.



Gecko: Worth prototyping (https://github.com/mozilla/standards-positions/issues/640)

WebKit: Positive (https://lists.webkit.org/pipermail/webkit-dev/2022-May/032254.html)

Web developers: Positive (https://github.com/whatwg/fetch/issues/1389) Example positive feedback: https://github.com/whatwg/fetch/issues/1389#issuecomment-1024726318 Example negative feedback: https://github.com/whatwg/fetch/issues/1389#issuecomment-1024880489

Other signals:

Ergonomics

This is a convenience function that is purely an ergonomic improvement.



Activation

The feature can be easily polyfilled.



Security

The feature adds no capabilities that developers don't already have. The implementation mostly reuses existing logic, reducing the security risk.



WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

No



Debuggability

Automatically supported as a feature implemented in WebIDL.



Is this feature fully tested by web-platform-tests?

Yes

Flag name



Requires code in //chrome?

False

Tracking bug

https://crbug.com/1305358

Non-OSS dependencies

Does the feature depend on any code or APIs outside the Chromium open source repository and its open-source dependencies to function?

No

Estimated milestones

No milestones specified



Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5197912798658560

This intent message was generated by Chrome Platform Status.

Yoav Weiss

unread,
Jun 1, 2022, 2:08:33 AMJun 1
to Adam Rice, blink-dev
On Tue, May 31, 2022 at 4:08 AM Adam Rice <ri...@chromium.org> wrote:

Contact emails

ri...@chromium.orgyhi...@chromium.org

Explainer

https://docs.google.com/document/d/1dTycWmyxLZNGTBW93fvtf1IQahx-vNwgu94yT1x9K50/edit

Specification

https://fetch.spec.whatwg.org/#ref-for-dom-response-json

Summary

Improves ergonomics for creating JSON Response objects. The Response constructor allows for creating the body of the response from many types, however it is not possible to directly create a JSON object. The Response.json() static method fills this gap. It returns a Response object with a body consisting the first argument serialized as JSON. The second argument is a ResponseInit option bag as with the Response constructor.



Blink component

Blink>Network>FetchAPI

Motivation

Creating a Response object with a body of a JSON object has been harder than the other types supported by Fetch. This change improves the ergonomics of creating a JSON response.



Initial public proposal

https://github.com/whatwg/fetch/issues/1389

TAG review

https://github.com/w3ctag/design-reviews/issues/741

The TAG review issue says they'd look into this next week. Given the fact that the issue was filed a couple of weeks ago, it seems reasonable to wait till then.
 


TAG review status

Pending

Risks



Interoperability and Compatibility

Interoperability risk is low as Deno and Node have already implemented the feature, and it is a simple addition to the API. We know of no compatibility risk. It could happen if someone is using a polyfill with an incompatible API, but that is unlikely.



Gecko: Worth prototyping (https://github.com/mozilla/standards-positions/issues/640)

WebKit: Positive (https://lists.webkit.org/pipermail/webkit-dev/2022-May/032254.html)

Web developers: Positive (https://github.com/whatwg/fetch/issues/1389) Example positive feedback: https://github.com/whatwg/fetch/issues/1389#issuecomment-1024726318 Example negative feedback: https://github.com/whatwg/fetch/issues/1389#issuecomment-1024880489

Great feedback from developers!!
 
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAC_ixdx%3DCG59iJ68vnOtRJC5ZCVK%2B4jing0n83HhkX2Kze%3DJiQ%40mail.gmail.com.

Chris Harrelson

unread,
Jun 22, 2022, 11:53:49 AMJun 22
to Yoav Weiss, Adam Rice, blink-dev

Yoav Weiss

unread,
Jun 22, 2022, 11:54:01 AMJun 22
to blink-dev, Chris Harrelson, Adam Rice, blink-dev, Yoav Weiss
LGTM2

On Wednesday, June 22, 2022 at 5:53:49 PM UTC+2 Chris Harrelson wrote:
LGTM1

On Tue, May 31, 2022 at 11:08 PM Yoav Weiss <yoav...@chromium.org> wrote:
On Tue, May 31, 2022 at 4:08 AM Adam Rice <ri...@chromium.org> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.

Philip Jägenstedt

unread,
Jun 22, 2022, 11:56:14 AMJun 22
to Yoav Weiss, blink-dev, Chris Harrelson, Adam Rice
LGTM3

The TAG review has been sitting for a month now, and this proposal has already received scrutiny in the spec discussion. If there's feedback (on naming or otherwise) before this reaches stable, we should take it into account.

On Wed, Jun 22, 2022 at 5:54 PM Yoav Weiss <yoav...@chromium.org> wrote:
LGTM2

On Wednesday, June 22, 2022 at 5:53:49 PM UTC+2 Chris Harrelson wrote:
LGTM1

On Tue, May 31, 2022 at 11:08 PM Yoav Weiss <yoav...@chromium.org> wrote:
On Tue, May 31, 2022 at 4:08 AM Adam Rice <ri...@chromium.org> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/d247eeaf-f3be-438f-b1f3-5ab6ee6e4594n%40chromium.org.

Daniel Bratell

unread,
Jun 22, 2022, 11:59:06 AMJun 22
to blink-dev, Philip Jägenstedt, blink-dev, Chris Harrelson, Adam Rice, yoav...@chromium.org
LGTM4 (yes, a bonus LGTM!). Given the data I think the risk is small enough.

Joe Medley

unread,
Jun 22, 2022, 1:09:21 PMJun 22
to Philip Jägenstedt, Yoav Weiss, blink-dev, Chris Harrelson, Adam Rice
Adam,

When are you hoping to ship?

Joe
Joe Medley | Technical Writer, Chrome DevRel | jme...@google.com | 816-678-7195
If an API's not documented it doesn't exist.


Adam Rice

unread,
Jun 23, 2022, 3:14:12 AMJun 23
to Joe Medley, Philip Jägenstedt, Yoav Weiss, blink-dev, Chris Harrelson
I expect to ship it in M105. I have updated chromestatus.com.

Joe Medley

unread,
Jun 23, 2022, 9:40:28 AMJun 23
to Adam Rice, Philip Jägenstedt, Yoav Weiss, blink-dev, Chris Harrelson
Thank you.

Joe Medley | Technical Writer, Chrome DevRel | jme...@google.com | 816-678-7195
If an API's not documented it doesn't exist.

Reply all
Reply to author
Forward
0 new messages