diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/api/performanceentry/tojson | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/ja/web/api/performanceentry/tojson')
-rw-r--r-- | files/ja/web/api/performanceentry/tojson/index.html | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/files/ja/web/api/performanceentry/tojson/index.html b/files/ja/web/api/performanceentry/tojson/index.html new file mode 100644 index 0000000000..adcf14851c --- /dev/null +++ b/files/ja/web/api/performanceentry/tojson/index.html @@ -0,0 +1,108 @@ +--- +title: PerformanceEntry.toJSON() +slug: Web/API/PerformanceEntry/toJSON +tags: + - API + - Web パフォーマンス + - メソッド + - リファレンス +translation_of: Web/API/PerformanceEntry/toJSON +--- +<div>{{APIRef("Performance Timeline API")}}</div> + +<p><strong><code>toJSON()</code></strong> メソッドは<em>シリアライザ</em>で、{{domxref("PerformanceEntry","パフォーマンスエントリ")}}オブジェクトの JSON 表現を返します。</p> + +<p>{{AvailableInWorkers}}</p> + +<h2 id="構文">構文</h2> + +<pre class="syntaxbox">json = perfEntry.toJSON(); +</pre> + +<h3 id="引数">引数</h3> + +<dl> + <dt>なし</dt> + <dd> </dd> +</dl> + +<h3 id="戻り値">戻り値</h3> + +<dl> + <dt>json</dt> + <dd>{{domxref("PerformanceEntry")}} オブジェクトのシリアル化である JSON オブジェクト</dd> +</dl> + +<h2 id="例">例</h2> + +<p>次の例は、<code>toJSON()</code> メソッドの使用方法を示しています。</p> + +<pre class="brush: js">function run_PerformanceEntry() { + log("PerformanceEntry support ..."); + + if (performance.mark === undefined) { + log("... performance.mark Not supported"); + return; + } + + // Create some performance entries via the mark() method + performance.mark("Begin"); + do_work(50000); + performance.mark("End"); + + // Use getEntries() to iterate through the each entry + var p = performance.getEntries(); + for (var i=0; i < p.length; i++) { + log("Entry[" + i + "]"); + check_PerformanceEntry(p[i]); + } +} +function check_PerformanceEntry(obj) { + var properties = ["name", "entryType", "startTime", "duration"]; + var methods = ["toJSON"]; + + for (var i=0; i < properties.length; i++) { + // check each property + var supported = properties[i] in obj; + if (supported) + log("..." + properties[i] + " = " + obj[properties[i]]); + else + log("..." + properties[i] + " = Not supported"); + } + for (var i=0; i < methods.length; i++) { + // check each method + var supported = typeof obj[methods[i]] == "function"; + if (supported) { + var js = obj[methods[i]](); + log("..." + methods[i] + "() = " + JSON.stringify(js)); + } else { + log("..." + methods[i] + " = Not supported"); + } + } +} +</pre> + +<h2 id="仕様">仕様</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">仕様書</th> + <th scope="col">ステータス</th> + <th scope="col">コメント</th> + </tr> + <tr> + <td>{{SpecName('Performance Timeline Level 2', '#dom-performanceentry-tojson', 'toJSON')}}</td> + <td>{{Spec2('Performance Timeline Level 2')}}</td> + <td><code>toJSON()</code> メソッドの初期定義</td> + </tr> + </tbody> +</table> + +<h2 id="ブラウザの互換性">ブラウザの互換性</h2> + +<div> +<div class="hidden">このページの互換性テーブルは構造化データから生成されます。データに貢献したい場合は <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックして、プルリクエストを送ってください。</div> + +<p>{{Compat("api.PerformanceEntry.toJSON")}}</p> +</div> |