There's one to many relationship to:
A1: value1
A2: value2
B1: value3
B2: value4
C1: value5
...
I wanna use prompt list action to achieve when I click A, it shows A1 and A2 on another prompt list menu, then click A2, I need to insert text "value2" on any place.
I try to use a external json file as my input, anyone can help me finish the code? Thank you in advance!
It might be better to preprocess your JSON to a different pattern – the double underscores there (__) clash with the syntax of Keyboard Maestro menu strings.
What do you want the menus and submenus to display ?
As @ComplexPoint says, the double-underscores mess things up -- the leading characters, eg "A", won't be displayed in the prompt but will be the only thing returned by the prompt. I've used your original JSON, but included a "Search and Replace" to swap them all for single underscores.
Then it's just a case of listing all the "top level" keys, picking one, listing all the keys for that choice, and combing the two chosen keys into a path to get the result:
There's probably quicker/cleaner ways to do this -- for a large "database" it might be better to work on only the match from the first choice rather than search the whole blob again -- but I'm so bad at JSON that I'm glad to get to "working" and not worry about "optimal"