Fix length reset in JSON parser