Package utils.common

Class DirectoryStructureToJson


  • public class DirectoryStructureToJson
    extends java.lang.Object
    Turns the file system of a directory to JSON

    Inspired by https://gist.github.com/shaiful16/863e05c349e34aec6851b6d9f0bc0034

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.fasterxml.jackson.databind.JsonNode get​(java.nio.file.Path base, boolean flatten)
      Turns the file system of the given directory to JSON.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DirectoryStructureToJson

        public DirectoryStructureToJson()
    • Method Detail

      • get

        public static com.fasterxml.jackson.databind.JsonNode get​(java.nio.file.Path base,
                                                                  boolean flatten)
                                                           throws java.io.IOException
        Turns the file system of the given directory to JSON. It does NOT check access rights.
        Parameters:
        base - File object of the base directory.
        flatten - If true, the returned JSON will be a list of files (not nested, no directories). If false, the returned JSON will have a nested file structure.
        Throws:
        java.io.IOException