Unfortunately, in practice that works only most of the time. At least in our experience (and the article says something similar) sometimes ChatGPT would return something completely different when JSON-formatted response would be expected.
https://gist.github.com/BLamy/244eec016beb9ad8ed48cf61fd2054...