Fix backtracking issue in json manipulations, fixes #2583