John was appointed to lead the first commission on Emperor Justinian's new legal code, the "Corpus Juris Civilis", and became Justinian's chief legal advisor. He was also appointed praetorian prefect of the East, giving him the power to introduce new taxes on the population. The new taxes were very unpopular, and the mob involved in the Nika riots of 532 demanded that both John the Cappadocian and the "quaestor sacri palatii" Tribonian be dismissed. Emperor Justinian did so, until the riots had been suppressed, after which he reinstated John as prefect and Tribonian as "quaestor". After the riots, which had been supported by upper-class Senators, John, who had the same lower-class background as Justinian, became even more important in political affairs. John influenced Emperor Justinian's military decisions, helping to draft the Eternal Peace with Khosrau I of Persia (531–579) and convincing Justinian not to empty the treasury with a large expedition against the Vandal kingdom in North Africa. John worked with the Byzantine emperor to reduce the size of the bureaucracy, both in Constantinople and in the provinces, developing a rudimentary meritocracy.