Fix completely broken JSON handling

Don't code too tired!