PerformanceNavigationTiming.toJSON()

The toJSON() method is a serializer - it returns a JSON representation of the PerformanceNavigationTiming object.

Syntax

toJSON()

Parameters

None.

Return value

A JSON object that is the serialization of the PerformanceNavigationTiming object as a map with entries from the closest inherited interface and with entries for each of the serializable attributes.

Examples

// Get a resource performance entry
const [entry] = performance.getEntriesByType("navigation");

// Get the JSON and log it
const json = entry.toJSON();
const s = JSON.stringify(json);
console.log(`PerformanceNavigationTiming.toJSON() = ${s}`);

Specifications

Specification
Navigation Timing Level 2
# dom-performancenavigationtiming-tojson

Browser compatibility

BCD tables only load in the browser