The pre-Masoretic Hebrew text literally has ‘to me’ (אלי). But this reading goes against the second part of the verse. In fact, in it (12:10b) we found twice the expression עליו, ‘over him’, referring - with no doubts – to the same subject expressed by the first part of the verse.
This contradiction was noted in the past.
In fact, in the Gesenius’ Hebrew Grammar (edited and enlarged by E. Kautzsch, and translated by A. E. Cowley (§ 138e [ft 1]) we found an interesting comment on this verse (bold is mine): “In Zechariah 12:10 also, instead of the unintelligible e·laʹi ēth a·sherʹ [אשׁר את אלי], we should probably read el-a·sherʹ, and refer the passage to this class.”
In his own translation, Emil F. Kautzsch (1890) himself rendered: “To that one whom”.
Between the ancient translations we found Theodotion (II cent.), which translated similarly “to him whom.”
An excerpt of modern Bible translations that follow this pattern is:
Bible in Basic English (BBE)
Good News Bible (GNB)
New American Bible (NAB) [catholic]
The New Jerusalem Bible (NJB).
Can the context of this verse help us to resolve this dilemma?
It depends in what manner we define context.
If, for me context – in this case – consists merely of the single verse (12:10) examined (someone may enlarge the range of the context by including the logic verses regrouping [vss. 10-11? 10-14?]) I’ll free to choose one between the two options the text presents me, that is,
 “to me” (not supposing any scribal error, so taking literally the text, but leaving in contradiction the first part of the verse with the second part),
 “to him” (supposing a scribal error, so not taking literally the text, but avoiding the two parts of the verse to remain in contradiction).
A very plausible possibility is also the following: the MT reading come from a text that included a scribal error in that point, whereas the Hebrew text used by John of Zebedee, and Theodotion also, after him, was a different one, a Hebrew text that not contained a scribal error in that place.
In other words, on the sole basis of Zechariah’s book itself we are not able to resolve this dilemma. In fact, we remain with these two different options.
However, this is one of Bible passages on which the context is defined, in some peculiar meanings, differently, according the context range’s extent of the scholars.
For example, if I believe all the Bible is the God message for men, I’ll consider all the Scriptures as a potential context of Zec 12:10. So, the passage of Joh 19:37 should offer me a direct reference to Zac 12:10, becoming part of the context of this OT verse. Clearly, John of Zebedee, with his phraseology confirms the correctness of the abovementioned option 2.
As you see, in this case, the comprehension of Zec 12:10 depends by the our context range’s extent.
Personally, instead thinking John (of Zebedee) misquoted Zechariah, I prefer to choose the option that the MT preserves a scribal error (like other many instances). Luckily, in the most of these occurrences, textual criticism, along with the use of the context, permit us to resolve the majority of these dilemmas.