BaseConfig.model_dump_json#

BaseConfig.model_dump_json(*, indent=None, include=None, exclude=None, context=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, round_trip=False, warnings=True, serialize_as_any=False)#

Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json

Generates a JSON representation of the model using Pydantic’s to_json method.

Args:

indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,

“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.

Returns:

A JSON string representation of the model.

Parameters:
  • indent (int | None)

  • include (Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | ~typing.Mapping[str, IncEx | ~typing.Literal[True]] | ~typing.Literal[True]] | ~typing.Mapping[str, ~typing.Set[int] | ~typing.Set[str] | ~typing.Mapping[int, IncEx | ~typing.Literal[True]] | ~typing.Mapping[str, IncEx | ~typing.Literal[True]] | ~typing.Literal[True]] | None)

  • exclude (Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | ~typing.Mapping[str, IncEx | ~typing.Literal[True]] | ~typing.Literal[True]] | ~typing.Mapping[str, ~typing.Set[int] | ~typing.Set[str] | ~typing.Mapping[int, IncEx | ~typing.Literal[True]] | ~typing.Mapping[str, IncEx | ~typing.Literal[True]] | ~typing.Literal[True]] | None)

  • context (Any | None)

  • by_alias (bool)

  • exclude_unset (bool)

  • exclude_defaults (bool)

  • exclude_none (bool)

  • round_trip (bool)

  • warnings (bool | Literal['none', 'warn', 'error'])

  • serialize_as_any (bool)

Return type:

str