Fixed bug when invalid keys encoding a JSON object would loop forever.