We are told that "he did right in the sight of the Lord, and walked in all the way of David his father, and turned not aside to the right hand or to the left." (verse 2)
Now Josiah followed a series of kings who had engaged in wickedness, strayed from the Lord and even established worship of heathen gods. But one day during the work to reconstruct the temple, Hilkiah the high priest found a book of the law. He gave the book to Shaphan the scribe who read it and took it to King Josiah and read it to him.
When the king heard the words he rent his clothes in anguish. Josiah commanded Hilkiah, Shaphan and three others to go to Hulda, a woman of Jerusalem who was a known prophet. Josiah charged that they ask her concerning God's will as he recognized that the "wrath of the Lord is kindled against us because our fathers have not hearkened unto the words of this book." (verse 13)
Hulda confirmed that God's wrath would not be quenched. But because the king has a tender heart and he humbled himself before the Lord, the people would not be spared, but the king would die before he saw the desolation of Jerusalem.
His emissaries brought him this word of the Lord through Hulda the Prophet.
Now read chapter 23 in which Josiah cleans house and discover the circumstances of his death.
Takeaway: The judgment of the Lord is stayed if we are contrite and repent of our sins.