"It doesn't work" is probably the most useless problem report we get - and we get it a lot. It tells us nothing about what is happening, or when it happens.
So tell us what it is doing that you didn't expect, or not doing that you did.
Tell us what you did to get it to happen.
Tell us any error messages.
In this case, we can't even begin to help you as we have no access to your JSON input, and no idea what it should dis0lay. And since we can't run your code and see without the input data, there isn;t anythign we can do to help you.
So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger: pdb — The Python Debugger — Python 3.11.4 documentation
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.
Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!