Generating G-code with Python is f-strings plus discipline: a formatter that never emits garbage, header and footer templates, and a feature loop. Full example inside.
JSON to G-code is not format conversion: JSON carries parameters, a generator turns them into programs. The schema-template pattern and its guardrails.
A G-code generator script is just a program printing text blocks from parameters. When scripting beats CAM, the structure every generator shares, and the guardrails.