Re: [whatwg/fetch] Add `Response.json` static method (PR #1392)

@annevk commented on this pull request.

Thanks, this looks good to me now modulo some final nits.

(It's a bit unfortunate JSON ended up with `application/json` rather than `text/json`. Most other web text formats use `text/`. And while I believe this might be the first place we directly expose it in the web platform, going with `text/json` would be rather brazen.)

> + <li><p>Set <var>response</var>'s <a for=Response>response</a>'s <a for=response>status message</a> to
  <var>init</var>["{{ResponseInit/statusText}}"].

```suggestion
 <li><p>Set <var>response</var>'s <a for=Response>response</a>'s <a for=response>status message</a>
 to <var>init</var>["{{ResponseInit/statusText}}"].
```

> +<p>To <dfn>initialize a response</dfn>, given a {{Response}} <var>response</var>, {{ResponseInit}}
+<var>init</var>, and an optional <a for=/>body with type</a> <var>body</var>, run these steps:

```suggestion
<p>To <dfn>initialize a response</dfn>, given a {{Response}} object <var>response</var>, 
{{ResponseInit}} <var>init</var>, and an optional <a for=/>body with type</a> <var>body</var>, run 
these steps:
```

> +<p>The static
+<dfn method for=Response><code>json(<var>data</var>, <var>init</var>)</code></dfn> method steps
+are:
+
+<ol>
+ <li><p>Let <var>bytes</var> the result of running <a>serialize a JavaScript value to JSON bytes</a>
+ on <var>data</var>.
+
+ <li><p>Let <var>body</var> be the result of <a for=BodyInit>extracting</a> <var>bytes</var>.
+
+ <li><p>Let <var>responseObject</var> be the result of <a for=Response>creating</a> a {{Response}}
+ object, given a new <a for=/>response</a>, "<code>response</code>", and <a>this</a>'s
+ <a>relevant Realm</a>.
+
+ <li><p>Perform <a>initialize a response</a> given <var>responseObject</var>, <var>init</var>, and
+ (body, "<code>application/json</code>").

```suggestion
 (<var>body</var>, "<code>application/json</code>").
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/pull/1392#pullrequestreview-971826690
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/pull/1392/review/971826690@github.com>

Received on Friday, 13 May 2022 07:48:39 UTC