model_dump_json#
- OutlineFile.model_dump_json(*, indent=None, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)#
- !!! abstract “Usage Documentation”
[model_dump_json](../concepts/serialization.md#modelmodel_dump_json)
Generates a JSON representation of the model using Pydantic’s to_json method.
- Parameters:
indent (
int
|None
) – Indentation to use in the JSON output. If None is passed, the output will be compact.include (
Union
[set
[int
],set
[str
],Mapping
[int
,Union
[set
[int
],set
[str
],Mapping
[int
,Union
[IncEx,bool
]],Mapping
[str
,Union
[IncEx,bool
]],bool
]],Mapping
[str
,Union
[set
[int
],set
[str
],Mapping
[int
,Union
[IncEx,bool
]],Mapping
[str
,Union
[IncEx,bool
]],bool
]],None
]) – Field(s) to include in the JSON output.exclude (
Union
[set
[int
],set
[str
],Mapping
[int
,Union
[set
[int
],set
[str
],Mapping
[int
,Union
[IncEx,bool
]],Mapping
[str
,Union
[IncEx,bool
]],bool
]],Mapping
[str
,Union
[set
[int
],set
[str
],Mapping
[int
,Union
[IncEx,bool
]],Mapping
[str
,Union
[IncEx,bool
]],bool
]],None
]) – Field(s) to exclude from the JSON output.context (
Any
|None
) – Additional context to pass to the serializer.by_alias (
bool
|None
) – Whether to serialize using field aliases.exclude_unset (
bool
) – Whether to exclude fields that have not been explicitly set.exclude_defaults (
bool
) – Whether to exclude fields that are set to their default value.exclude_none (
bool
) – Whether to exclude fields that have a value of None.round_trip (
bool
) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].warnings (
Union
[bool
,Literal
['none'
,'warn'
,'error'
]]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].fallback (
Optional
[Callable
[[Any
],Any
]]) – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.serialize_as_any (
bool
) – Whether to serialize fields with duck-typing serialization behavior.
- Return type:
- Returns:
A JSON string representation of the model.