Skip to content

Add parameter to add the values from json as default values in the model #40

@teodor-t-tenev

Description

@teodor-t-tenev

Describe

It would be great if there is an option to add the values from json as default values in the Model

Reproduce (Optional)

Package version: ...

JSON data:

{
  "name": "John Smith",
  "hometown": {
    "name": "New York",
    "id": 123
  }
}
...

Desired result

A clear and concise description of what you want to happen.
Class code:

r"""
generated by json2python-models v0.2.4 at Tue Oct 19 22:08:54 2021
command: /Users/teodor.tenev/PycharmProjects/TestProj/venv/bin/json2models -m Car package.json -f dataclasses
"""
from dataclasses import dataclass, field
from typing import Literal

@dataclass
class Hometown:
    name: Literal["New York"] = 'New York'
    id_: int = 123

@dataclass
class Car:
    hometown: 'Hometown' = Hometown()
    name: Literal["John Smith"] = 'John Smith'
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLICommand line agruments and related codeenhancementNew feature or requestwontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions