You would also need to keep generating until the whole string is valid. And what if it gets caught in a loop?
Not sure how this can really guarantee 100%
Not sure how this can really guarantee 100%
It's not great but after some timeout you can just set the mask to only include closing brackets.
{"this": "is valid json so farrrrrrrrrrrrrr
But yeah the general idea makes sense. Once you hit a timeout, change the mask to things that will close existing open things in a valid manner (}, ), ], ")