Follow-up for bug#9962: make JSON handling more robust and simple.