Well, “ji” is derived from “ajja/ajji” which in turn is derived from “ayya” of Prakrits, which in turn is derived from “arya/arye” of Sanskrit.
The intermediate forms “ajja/ajje” is seen as examples in Sanskrit dramas.
For example, in Shudraka’s Mrcchakatikam, first canto, during the introduction, the actress (naTI नटी) enters and speaks with the director (sUtradhAra सूत्रधारः) —
नटी — [ प्रविश्य ] अज्ज ! इअं ह्मि (आर्य ! इयमस्मि)
सूत्रधारः — अज्जे ! साअदं दे ( आर्ये ! स्वागतं ते )
नटी — आणवेदु अज्जो को णिओओ अणुचिट्ठीअदु त्ति ( आज्ञापयतु आर्यः को नियोगोऽनुष्ठीयतामिति )
So you see the Sanskrit dramatists wrote dialogues in both Prakrit and Sanskrit, and you can easily see the close relationship of the words “ajja/ajje” and “arya/arye”.