Back to Content

NotRestoredReasonDetails: toJSON() method

files/en-us/web/api/notrestoredreasondetails/tojson/index.md

latest1.2 KB
Original Source

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

The toJSON() method of the {{domxref("NotRestoredReasonDetails")}} interface is a {{Glossary("Serialization","serializer")}}; it returns a JSON representation of the {{domxref("NotRestoredReasonDetails")}} object.

Syntax

js-nolint
toJSON()

Parameters

None.

Return value

A {{jsxref("JSON")}} object that is the serialization of the {{domxref("NotRestoredReasonDetails")}} object.

Examples

The following function will return a JSON representation of the first NotRestoredReasonDetails object of the NotRestoredReasons object from the first PerformanceNavigationTiming object currently present in the performance timeline:

js
function returnNRR() {
  const navEntries = performance.getEntriesByType("navigation");
  let navEntry = navEntries[0];
  return navEntry.notRestoredReasons.reasons[0].toJSON();
}

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also