The reality is, you end up with a complex stack with no or homegrown documentation that requires experienced engineers to operate and maintain.
In some environments, that's a perfectly fair trade-off. In most, it isn't.
And guess what, the switch may decide to print informational or environmental messages interleaved with the command output, because the commands were meant to be run by a human. Good luck knowing if your state-altering command succeeded when you receive broken JSON.
I ended up regex-removing known environmental messages from command outputs..
You can already run plain Debian on a Mellanox Spectrum device, treat it like a Linux software router, and by the power of magic your routes get pushed into hardware. (Source: device on my table to my right :D) Microchip's SparX-5 should be similar though I don't have one of those to test.
The only switching/routing vendor with an API worth a damn was Juniper - in fact they were the only vendor who was applying CLI changes to the box via their own API, the Way It Should Be Done™.
These days you are spoilt for choice (and price point) with the likes of Arista, HPe (AOS-CX), Cisco (NX-OS, IOS-XR) and plenty of others entering the space.
Vote with your wallet!