88![ Example] ( /etc/convert.png )
99
1010json2python-models is a [ Python] ( https://www.python.org/ ) tool that can generate Python models classes
11- (dataclasses, [ attrs] ( https://github.com/python-attrs/attrs ) ) from JSON dataset.
11+ ([ pydantic] ( https://github.com/samuelcolvin/pydantic ) , dataclasses, [ attrs] ( https://github.com/python-attrs/attrs ) )
12+ from JSON dataset.
1213
1314## Features
1415
@@ -17,11 +18,11 @@ json2python-models is a [Python](https://www.python.org/) tool that can generate
1718* Fields and models ** names** generation (unicode support included)
1819* Similar ** models generalization**
1920* Handling ** recursive data** structures (i.e family tree)
20- * Detecting ** string literals ** (i.e. datetime or just stringify numbers)
21- and providing decorators to easily convert into Python representation
21+ * Detecting ** string serializable types ** (i.e. datetime or just stringify numbers)
22+ * Detecting fields containing string constants ( ` Literal['foo', 'bar'] ` )
2223* Generation models as ** tree** (nested models) or ** list**
2324* Specifying when dictionaries should be processed as ** ` dict ` type** (by default every dict is considered as some model)
24- * ** CLI** tool
25+ * ** CLI** API with a lot of options
2526
2627## Table of Contents
2728
@@ -313,8 +314,8 @@ Arguments:
313314
314315* ` -f ` , ` --framework ` - Model framework for which python code is generated.
315316 ` base ` (default) mean no framework so code will be generated without any decorators and additional meta-data.
316- * ** Format** : ` -f {base,attrs,dataclasses,custom} `
317- * ** Example** : ` -f attrs `
317+ * ** Format** : ` -f {base, pydantic, attrs, dataclasses, custom} `
318+ * ** Example** : ` -f pydantic `
318319 * ** Default** : ` -f base `
319320
320321* ` -s ` , ` --structure ` - Models composition style.
@@ -331,6 +332,13 @@ Arguments:
331332
332333* ` --strings-converters ` - Enable generation of string types converters (i.e. ` IsoDatetimeString ` or ` BooleanString ` ).
333334 * ** Default** : disabled
335+
336+ * ` --max-strings-literals ` - Generate ` Literal['foo', 'bar'] ` when field have less than NUMBER string constants as values.
337+ * ** Format** : ` --max-strings-literals <NUMBER> `
338+ * ** Default** : 10 (generator classes could override it)
339+ * ** Example** : ` --max-strings-literals 5 ` - only 5 literals will be saved and used to code generation
340+ * ** Note** : There could not be more than ** 15** literals per field (for performance reasons)
341+ * ** Note** : ` attrs ` code generator do not use Literals and just generate ` str ` fields instead
334342
335343* ` --merge ` - Merge policy settings. Possible values are:
336344 * ** Format** : ` --merge MERGE_POLICY [MERGE_POLICY ...] `
@@ -373,7 +381,7 @@ One of model arguments (`-m` or `-l`) is required.
373381
374382### Low level API
375383
376- > Coming soon (Wiki)
384+ \-
377385
378386## Tests
379387
0 commit comments