PerformanceEntry: toJSON() メソッド
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.
toJSON()
メソッドはシリアライザーで、この PerformanceEntry
オブジェクトの JSON 表現を返します。
構文
js
toJSON()
引数
なし。
返値
JSON
お武衛ジェクトで、この PerformanceEntry
オブジェクトをシリアライズしたものです。
例
toJSON メソッドの使用
この例では、 entry.toJSON()
を呼び出すとその PerformanceMark
オブジェクトの JSON 表現を返します。
js
performance.mark("debug-marker", {
detail: "debugging-marker-123",
});
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
console.log(entry.toJSON());
});
});
observer.observe({ entryTypes: ["mark"] });
これは JSON オブジェクトを次のように出力します。
json
{
"name": "debug-marker",
"entryType": "mark",
"startTime": 158361,
"duration": 0
}
PerformanceMark
の detail
プロパティが格納されていないことに注意してください。
JSON 文字列を取得するには、 JSON.stringify(entry)
を直接使用することができます。これは toJSON()
を自動的に呼び出します。
仕様書
Specification |
---|
Performance Timeline # dom-performanceentry-tojson |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
toJSON |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.