Convert a directory structure in the filesystem to JSON