https://github.com/itzg/file-tree-as-json
Walks one or more directories capturing the file/directory tree into a JSON format
https://github.com/itzg/file-tree-as-json
Last synced: over 1 year ago
JSON representation
Walks one or more directories capturing the file/directory tree into a JSON format
- Host: GitHub
- URL: https://github.com/itzg/file-tree-as-json
- Owner: itzg
- Created: 2022-12-15T04:12:16.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-17T23:33:08.000Z (over 1 year ago)
- Last Synced: 2025-03-18T00:29:44.538Z (over 1 year ago)
- Language: Java
- Size: 141 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Walks one or more directories capturing the file/directory tree into a JSON format.
## Usage
```
Usage: file-tree-as-json [-h] [--debug] [-o=FILE] PATH...
PATH... One or more paths to process
--debug Enable debug logs
-h, --help Show usage
-o, --output=FILE If not provided, JSON is output to stdout
```
## Example output
```json
{
"C:\\projects\\file-tree-as-json\\src" : {
"children" : [ {
"path" : "main",
"children" : [ {
"path" : "java",
"children" : [ {
"path" : "app",
"children" : [ {
"path" : "FilenameSerializer.java"
}, {
"path" : "FileTreeAccumulator.java"
}, {
"path" : "FileTreeAsJson.java"
}, {
"path" : "FileTreeEntry.java"
} ]
} ]
}, {
"path" : "resources",
"children" : [ {
"path" : "logback.xml"
}, {
"path" : "schema.json"
} ]
} ]
}, {
"path" : "test",
"children" : [ {
"path" : "java",
"children" : [ ]
}, {
"path" : "resources",
"children" : [ ]
} ]
} ]
}
}
```
## Output Schema
```json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"description": "Map of root paths to its tree",
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"children": {
"type": "array",
"items": {
"$ref": "#/definitions/FileTreeEntry"
}
}
}
},
"definitions": {
"FileTreeEntry": {
"type": "object",
"properties": {
"path": {
"description": "The subpath of this entry",
"type": "string"
},
"children": {
"description": "If present, indicates that this subpath is a directory with the given entries",
"type": "array",
"items": {
"$ref": "#/definitions/FileTreeEntry"
}
}
},
"required": ["path"]
}
}
}
```