ReportBody: toJSON() method
Note: This feature is available in Web Workers.
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
The toJSON()
method of the ReportBody
interface is a serializer, and returns a JSON representation of the ReportBody
object.
Syntax
toJSON()
Parameters
None.
Return value
A JSON object that is the serialization of the ReportBody
object.
Examples
In this example we create a new ReportingObserver
to observe intervention reports, then return a JSON representation of the first entry. The report, and therefore the JSON object returned will be an instance of InterventionReportBody
which inherits from ReportBody
.
const options = {
types: ["intervention"],
buffered: true,
};
const observer = new ReportingObserver(([firstReport], observer) => {
console.log(firstReport.toJSON());
}, options);
Specifications
No specification found
No specification data found for api.ReportBody.toJSON
.
Check for problems with this page or contribute a missing spec_url
to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.