Access WordPress Properties/Attributes of Custom Block in PHP

I have created my first WordPress Block using the npm package. It is an FAQ setup that takes a string for a question and InnerBlocks for the content.

As well as rendering this block, I want to create an JSON Schema for search engines that outputs the JSON Schema in the <head>. It should take each one of these FAQ blocks on any given post and place the value of the question attribute and the content of the inner block in the relevant question and answer field of the JSON Schema.

I can do this dynamically with javascript but I don’t think that is the correct approach as this JSON Schema should be output directly in the <head>.

So I thought I should extract these attribute values in PHP and create a function that would inject the JSON schema to wp_head. But I found this equally impossible. I can’t access these attributes in PHP. I tried creating a custom render.php but found that the HTML attributes were not included in $attributes. The only way I can see to do this is with an OB_Clean using add_filter to examine and extract what I want from the HTML.

Surely there is a way to extract the attribute values in PHP then create a global that accumulates all these, builds the <script> and adds it to wp_head?

Or am I overthinking this? I can’t find documentation on reading the attribute values in php at all. What am I missing?