Convert enchantments components into explicit list - 1.20.6

I want to convert the enchantments component which is structured like that : {"minecraft:enchantments": {levels: {"minecraft:sharpness": 5, "minecraft:unbreaking": 3}}} into an explicit list of enchantments (as it was before 1.20.5) which would look like this : enchantments:[{id:"minecraft:sharpness",level:5},{id:"minecraft:unbreaking",level:3}]

How can I achieve this ? Is it even possible ?

The idea behind is first to compare enchanted book enchantments to a database and then use macros to enchant items from it. I plan to use /enchant command so the resulting item doesn't have unappropriate enchantments applied to it, such as efficiency on a sword.

Continue to help post