PushMessageData: json() メソッド
Baseline 2023Newly available
Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
json()
は PushMessageData
インターフェイスのメソッドで、プッシュメッセージのデータを JSON 文字列として解釈し、結果を返します。
構文
js
json()
引数
なし。
返値
プッシュイベントのデータを JSON として解釈した結果です。これは JSON で表現されるあらゆるものになり得ます。オブジェクト、配列、文字列、数値などです。
例
js
self.addEventListener("push", (event) => {
const myData = event.data.json();
// JSON を使って何かを実行する
});
仕様書
Specification |
---|
Push API # dom-pushmessagedata-json |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
json |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
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.