Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonw/json-to-files
Create separate files on disk based on a JSON object
https://github.com/simonw/json-to-files
Last synced: 27 days ago
JSON representation
Create separate files on disk based on a JSON object
- Host: GitHub
- URL: https://github.com/simonw/json-to-files
- Owner: simonw
- License: apache-2.0
- Created: 2023-01-10T20:09:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-10T20:15:20.000Z (almost 2 years ago)
- Last Synced: 2024-10-06T20:53:00.006Z (about 1 month ago)
- Language: Python
- Size: 7.81 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-to-files
[![PyPI](https://img.shields.io/pypi/v/json-to-files.svg)](https://pypi.org/project/json-to-files/)
[![Changelog](https://img.shields.io/github/v/release/simonw/json-to-files?include_prereleases&label=changelog)](https://github.com/simonw/json-to-files/releases)
[![Tests](https://github.com/simonw/json-to-files/workflows/Test/badge.svg)](https://github.com/simonw/json-to-files/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/json-to-files/blob/master/LICENSE)Create separate files on disk based on a JSON object
## Installation
Install this tool using `pip`:
pip install json-to-files
## Usage
This tool takes a JSON file that looks like this:
```json
{
"foo.txt": "The contents of foo.txt",
"bar/baz.txt": "The contents of baz.txt"
}
```
And uses it to write out the following files on disk:- `foo.txt` containing "The contents of foo.txt"
- `bar/baz.txt` containing "The contents of baz.txt"You can run it like this:
json-to-files bundle.json
Or you can specify a directory to write those files to:
json-to-files bundle.json -d /tmp/other-directory
The `bundles.json` file name is optional - if omitted, this tool will read from standard input:
cat bundle.json | json-to-files
## Development
To contribute to this tool, first checkout the code. Then create a new virtual environment:
cd json-to-files
python -m venv venv
source venv/bin/activateNow install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest