InteractionContentfulPaint: toJSON() method

The toJSON() method of the InteractionContentfulPaint interface is a serializer; it returns a JSON representation of the InteractionContentfulPaint object.

Syntax

js
toJSON()

Parameters

None.

Return value

A JSON object that is the serialization of the InteractionContentfulPaint object.

Examples

Using the toJSON method

In this example, calling entry.toJSON() returns a JSON representation of the InteractionContentfulPaint object.

js
const observer = new PerformanceObserver((list) => {
  list.getEntries().forEach((entry) => {
    console.log(entry.toJSON());
  });
});

observer.observe({ type: "interaction-contentful-paint", buffered: true });

This would log a JSON object like so:

json
{
  "entryType": "interaction-contentful-paint",
  "interactionId": 1704,
  "largestContentfulPaint": <not shown>,
  "name": "",
  "navigationId": 2463,
  "paintTime": 2589.3,
  "presentationTime": 2616,
  "startTime": 2226.6,
}

To get a JSON string, you can use JSON.stringify(entry) directly; it will call toJSON() automatically.

Specifications

This feature does not appear to be defined in any specification.

Browser compatibility

See also