I have a folder (root folder) with thousands of sub folders and
*.json files inside sub folders. How can I get list of sub folder names inside folder (root folder) using
file_scan_directory usually returns directories then perhaps you can use the regex mask to search for names that don't have a dot (.) in them.
There are very few files in a Drupal installation that don't have an extension, and I imagine there will be none in your folder structure if all it contains is .json files...
The above should match all items in the directory structure that don't contain a dot, thanks to this answer.