Skip to content

Commit 0e04fce

Browse files
committed
README
1 parent 49b6a38 commit 0e04fce

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
[![json2python-models](/etc/logo.png)](https://github.com/bogdandm/json2python-models)
2+
3+
# JSON to Python models
4+
5+
[![PyPI version](https://badge.fury.io/py/json2python-models.svg)](https://badge.fury.io/py/json2python-models)
6+
[![Build Status](https://travis-ci.org/bogdandm/json2python-models.svg?branch=master)](https://travis-ci.org/bogdandm/json2python-models)
7+
[![Coverage Status](https://coveralls.io/repos/github/bogdandm/json2python-models/badge.svg?branch=master)](https://coveralls.io/github/bogdandm/json2python-models?branch=master)
8+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/11e13f2b81d7450eb0bca4b941d16d81)](https://www.codacy.com/app/bogdandm/json2python-models?utm_source=github.com&utm_medium=referral&utm_content=bogdandm/json2python-models&utm_campaign=Badge_Grade)
9+
10+
![Example](/etc/convert.png)
11+
12+
json2python-models is a [Python](https://www.python.org/) tool that can generate Python models classes
13+
(dataclasses, attrs) from JSON dataset.
14+
15+
It could handle recursive data structures, detect complex datatypes, generalize similar models, etc.
16+
17+
## Features
18+
19+
* Full `typing` module support
20+
* Types merging - if some field could contains data of different types it will handle it
21+
* Fields and models names generation (unicode support included)
22+
* Similar models generalization
23+
* Handling recursive data structures (i.e family tree)
24+
* Detecting string literals (i.e. datetime or just stringify numbers)
25+
* Generation models as tree (nested models) or list
26+
* Specifying when dictionaries should be processed as is
27+
* CLI tool
28+
29+
## Installation
30+
31+
> **Be ware**: it supports only `python3.7` and higher.
32+
33+
To install Requests, use `pip`:
34+
35+
`pip install`
36+
37+
Or you can build it from source:
38+
39+
```
40+
git clone https://github.com/bogdandm/json2python-models.git
41+
cd json2python-models
42+
python setup.py install
43+
```
44+
45+
46+
## Tests
47+
48+
To run tests you should clone project and install `pytest` and `requests` (to download online datasets):
49+
50+
```
51+
git clone https://github.com/bogdandm/json2python-models.git
52+
cd json2python-models
53+
pip install pytest>=4.4.0
54+
python setup.py install
55+
python setup.py test -a '<pytest arguments>'
56+
or
57+
pytest tests
58+
```
59+
60+
Also I would recommend you to install `pytest-xdist` for parallel execution
61+
and `pytest-sugar` for pretty printing test results
62+
63+
### Test examples
64+
65+
>
66+
67+
## Built With
68+
69+
* [python-dateutil](https://github.com/dateutil/dateutil) - Datetime parsing
70+
* [inflection](https://github.com/jpvanhal/inflection) - String transformations
71+
* [Unidecode](https://pypi.org/project/Unidecode/) - Unicode to ASCII conversion
72+
* [Jinja2](https://github.com/pallets/jinja) - Code templates
73+
* [ordered-set](https://github.com/LuminosoInsight/ordered-set) is used in models merging algorithm
74+
75+
## Contributing
76+
77+
Feel free to open pull requests with new features or bug fixes. Just follow few rules:
78+
1. Always use some code formatter ([black](https://github.com/ambv/black) or PyCharm built-in)
79+
2. Keep code coverage above 95-98%
80+
3. All existing tests should be passed (including test examples)
81+
4. Use `typing` module
82+
5. Fix [codacy](https://app.codacy.com/project/bogdandm/json2python-models/dashboard) issues
83+
84+
## License
85+
86+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

etc/convert.png

25.6 KB
Loading

etc/logo.png

17.2 KB
Loading

0 commit comments

Comments
 (0)