Note that when it comes to literal versus figurative use of language, it does not matter what the language is. In other words, there is nothing inherent in the Hebrew language versus the English language that helps determine if a word, phrase, or clause should be taken literally or figuratively.
Rather, context of a statement, in any language, is primarily going to be the factor that helps one determine the level of literalness intended.
Argument for a Literal Reading
[All Scripture quotations from the NASB.]
Josiah followed after his ancestor David in following after YHWH (2 Kg 22:2), when at the age of 16, eight years into his young reign, "he began to seek the God of his father David" (2 Chr 34:3a).
Just as David, Josiah "did not turn aside to the right or to the left" (2 Chr 34:2; cf. 2 Kg 22:2), meaning both worshiped YHWH alone once they turned to Him.
Yet Scripture does state, as you have noted from 2 Kg 23:25:
Before him [Josiah] there was no king like him who turned to the LORD with all
his heart and with all his soul and with all his might, according to
all the law of Moses; nor did any like him arise after him.
What did Josiah do after turning to God at the age of 16 (the 8th year of his reign), that helps one understand this statement?
At the age of 20 (12th year of his reign) he began thoroughly purging Israel of its idolatry and wicked practices (2 Kg 23:4-20, 24; 2 Chr 34:3b-7). David never set out to do that.
At the age of 26 (18th year of his reign; 2 Kg 22:3; 2 Chr 34:8), after having set about to see the temple repaired (2 Kg 22:4-7; 2 Chr 34:8-14), discovers "the book of the Law" (i.e. the Pentateuch, the five books of Moses) that had apparently been missing for some time (2 Kg 22:8-11; 2 Chr 34:14-21), and upon reading from it Josiah does three things:
Personally humbles himself to God, fearing the curses that were due to come to the people of Israel (2 Kg 22:18-19); David had himself personally sinned and did not care of some of Israel died for it (2 Sam 11, esp. v.15, 25).
Causes the nation to turn as one back to God, calling for a renewing of the covenant (2 Kg 23:1-3); David's choices caused a split both in his own family (2 Sam 12:10-12; 2 Sam 13:21, 23), and thus ultimately the nation (2 Sam 15).
Restores the Passover (2 Kg 23:21-23; 2 Chr 35:1-19), and significantly 2 Chr 35:18 states of Josiah's fervency in this:
There had not been celebrated a Passover like it in Israel since the days of Samuel the prophet [2 Kg 23:22 states it, "Surely such a Passover had not been celebrated from the days of the judges who judged Israel," which was Samuel's time, and prior to the reign of King David]; nor had any of the kings of Israel celebrated such a Passover as Josiah did with the priests, the Levites, all Judah and Israel who were present, and the inhabitants of Jerusalem.
This was a proper celebration of the Passover, something even David had not performed.
And after doing this, Josiah kept Israel pure during his lifetime, 2 Chr 34:33 states:
Josiah removed all the abominations from all the lands belonging to
the sons of Israel, and made all who were present in Israel to serve
the LORD their God. Throughout his lifetime they did not turn from
following the LORD God of their fathers.
King David did have a heart to follow God, and be obedient to Him, that was why he was selected over Saul when the latter had failed to be obedient (1 Sam 13:14, 15:28; 16:1-13). David had faith in God; Josiah likewise had faith in God—but the latter was more diligent to follow, and have Israel follow, "all the law of Moses."
So the literal reading is confirmed in the very contexts speaking about King Josiah. He "turned ... according to all the law of Moses," even in ways above and beyond what King David had ever done. The statement about Josiah is not about how great a king he was overall (in battle, as politician, financial wisdom, diplomat, etc.), but simply that in his zeal for following only YHWH and His law in the worship outlined by that law, there had been no greater king in Israel.