Javascript Recursion/JSON

I’m trying to build a nested JSON list from UL/LI elements, but I just can’t get it work with recursion. I have an example here. You can see the javascript I’ve written and my ideal output.

Can anyone help me?!

404 error. look up for examples.

Yeah, I should have deleted this. It turned out to be a variable scope issue. Thanks though!