Skip to content

json

JSON configuration file generator.

Generates JSON configuration files from Pydantic settings models.

Classes:

Classes

JsonGeneratorSettings pydantic-model

Bases: BaseModel

Configuration for JSON generator.

Show JSON schema:
JSON
{
  "description": "Configuration for JSON generator.\n\nGenerator name: `json`.",
  "properties": {
    "paths": {
      "description": "Output file paths",
      "items": {
        "format": "path",
        "type": "string"
      },
      "title": "Paths",
      "type": "array"
    },
    "indent": {
      "default": 2,
      "description": "JSON indentation spaces",
      "title": "Indent",
      "type": "integer"
    }
  },
  "title": "JsonGeneratorSettings",
  "type": "object"
}

Fields:

Attributes

paths pydantic-field
Python
paths: list[Path]

Output file paths

indent pydantic-field
Python
indent: int = 2

JSON indentation spaces

JsonGenerator

Bases: AbstractGenerator

Generate JSON configuration files.

Methods:

Functions

generate_single
Python
generate_single(settings_info: SettingsInfoModel, level: int = 1) -> str

Generate JSON format configuration.

Parameters:

  • settings_info (SettingsInfoModel) –

    Settings information model

  • level (int, default: 1 ) –

    Nesting level, by default 1

Returns:

  • str

    Generated JSON content

_parse_value
Python
_parse_value(field: FieldInfoModel) -> Any

Parse field value to appropriate Python type.

Parameters:

  • field (FieldInfoModel) –

    Field information

Returns:

  • Any

    Parsed value

Functions