public String folderContentToString(final Folder root, final boolean extendedInfo, final boolean pretty) {
        final Stack<ArrayNode> parents = new Stack<>();
        final ArrayNode currFolder = JsonUtils.createArrayNode();
        parents.push(currFolder);

        treeWalk(root, true, fi -> {
            if (fi.left.isDirectory) {
                if (fi.right) { //before
                    final ArrayNode newDirContent = JsonUtils.createArrayNode();
                    final ObjectNode newDirEntry = JsonUtils.createObjectNode();
                    newDirEntry.put("name", fi.left.name);
                    newDirEntry.set("files", newDirContent);
                    parents.peek().add(newDirEntry);
                    parents.push(newDirContent);
                    return TreeWalkResult.CONTINUE;
                } else {
                    parents.pop();
                    return TreeWalkResult.CONTINUE;
                }
            } else {
                if (extendedInfo) {
                    final ObjectNode fileEntry = JsonUtils.createObjectNode();
                    fileEntry.put("name", fi.left.name);
                    fileEntry.put("uri", String.valueOf(fi.left.uri));
                    fileEntry.put("mimeType", fi.left.mimeType);
                    parents.peek().add(fileEntry);
                } else {
                    parents.peek().add(fi.left.name);
                }
                return TreeWalkResult.CONTINUE;
            }
        });

        return pretty ? currFolder.toPrettyString() : currFolder.toString();

    }
Generates a string representation of given folder as JSON string

@param root         folder to generate string rep from
@param extendedInfo if false then only folder/file names are contained. If true, then more detailled info per file is contained
@param pretty       if false then info is delivered as "flat string". If true, info is delivered "pretty-printed" with line-breaks etc
@return string rep of folder
main/src/main/java/cgeo/geocaching/storage/FolderUtils.java