Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The toJSON() method of the PerformanceTimingConfidence interface is a serializer that returns a JSON representation of the PerformanceTimingConfidence object.
toJSON()None.
A JSON object that is the serialization of the PerformanceTimingConfidence object.
This example uses a PerformanceObserver to retrieve a JSON serialization of the confidence data for observed PerformanceNavigationTiming entries.
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
console.log(entry.confidence.toJSON());
});
});
observer.observe({ type: "navigation", buffered: true });This would log a JSON object like so:
{
"randomizedTriggerRate": 0.4994798,
"value": "high"
}To get a JSON string, you can use JSON.stringify(entry) directly; it will call toJSON() automatically.