Fix an oob-read in the json writer