Title: WP_Speculation_Rules::jsonSerialize
Published: April 28, 2025

---

# WP_Speculation_Rules::jsonSerialize()

[ Back to top](https://developer.wordpress.org/reference/classes/wp_speculation_rules/jsonserialize/?output_format=md#wp--skip-link--target)

## Source

    ```php
    public function jsonSerialize() {
    	// Strip the IDs for JSON output, since they are not relevant for the Speculation Rules API.
    	return array_map(
    		static function ( array $rules ) {
    			return array_values( $rules );
    		},
    		array_filter( $this->rules_by_mode )
    	);
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-speculation-rules.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-speculation-rules.php#L236)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-speculation-rules.php#L236-L244)

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_speculation_rules%2Fjsonserialize%2F)
before being able to contribute a note or feedback.