--- title: PushMessageData.json() slug: Web/API/PushMessageData/json tags: - PushMessageData.json() translation_of: Web/API/PushMessageData/json ---

{{APIRef("Push API")}}{{SeeCompatTable()}}

{{domxref("PushMessageData")}} 接口的 json()方法将推送消息数据提取为 一个 JSON 对象。

Syntax

let massage_Json = PushEvent.data.json();

Parameters

None.

Returns

A JSON object.

Examples

self.addEventListener('push', function(event) {
  var jsonObj = event.data.json();

  // do something with your JSON
});

Specifications

Specification Status Comment
{{SpecName('Push API', '#widl-PushMessageData-json-JSON', 'json()')}} {{Spec2('Push API')}} Initial definition.

Browser Compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatChrome(50.0)}} {{CompatGeckoDesktop(44.0)}}[1] {{CompatNo}} {{CompatNo}} {{CompatNo}}
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatNo}} {{CompatNo}} {{CompatGeckoMobile(48)}}[2] {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatChrome(50.0)}}

See also