TaskAttributionTiming: toJSON() メソッド

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。

toJSON()TaskAttributionTiming インターフェイスのメソッドで、シリアライザーです。これは TaskAttributionTiming オブジェクトの JSON 表現を返します。

構文

js
toJSON()

引数

なし。

返値

JSON オブジェクトで、 TaskAttributionTiming オブジェクトをシリアライズしたものです。

toJSON メソッドの使用

この例では、 entry.toJSON() を呼び出すと、TaskAttributionTiming オブジェクトの JSON 表現が返されます。

js
const observer = new PerformanceObserver((list) => {
  list.getEntries().forEach((entry) => {
    console.log(entry.toJSON());
  });
});

observer.observe({ type: "taskattribution", buffered: true });

次のような JSON オブジェクトをログ出力します。

json
{
  "name": "unknown",
  "entryType": "taskattribution",
  "startTime": 0,
  "duration": 0,
  "containerType": "window",
  "containerSrc": "",
  "containerId": "",
  "containerName": ""
}

JSON 文字列を取得するのであれば、直接 JSON.stringify(entry) を使用することができます。これは自動的に toJSON() を呼び出します。

仕様書

Specification
Long Tasks API
# dom-taskattributiontiming-tojson

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
toJSON
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.

関連情報