JSON Pointer is weak for this very reason. JSON Path is much better for this use case.
JSON PATCH unfortunately leverages JSON Pointer, and that too must be updated to be able to use JSON PATH instead. I am sure the authors will have heartburn. But to preprocess the data and then determine the index value to construct the JSON Pointer statement renders it obsolete.