By the time I wrote this question I used PHP 7.1 and had Autoptimize on for JS scripts. Now I have PHP 7.2 and I turned off Autoptimize for JS and now it seems to work (?) I guess.
Sorry for replying so late. I’m using PHP 7.2.
Update: I cleared the thumbnail, HTML and CSS cache and JSON works again, but if I refresh the page, it goes back to being bugged.