Thanks for sharing your project @extender777!
Did you look into specifying the use of structured output:
This should impose a hard requirement on the data format of the response (which, as you discovered, is not guaranteed if you instead specify the format via the prompt).