MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / model_dump_json

Method model_dump_json

src/opencode_ai/_models.py:310–359  ·  view source on GitHub ↗

Usage docs: https://docs.pydantic.dev/2.4/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

(
            self,
            *,
            indent: int | None = None,
            include: IncEx | None = None,
            exclude: IncEx | None = None,
            by_alias: bool = False,
            exclude_unset: bool = False,
            exclude_defaults: bool = False,
            exclude_none: bool = False,
            round_trip: bool = False,
            warnings: bool | Literal["none", "warn", "error"] = True,
            context: dict[str, Any] | None = None,
            serialize_as_any: bool = False,
        )

Source from the content-addressed store, hash-verified

308
309 @override
310 def model_dump_json(
311 self,
312 *,
313 indent: int | None = None,
314 include: IncEx | None = None,
315 exclude: IncEx | None = None,
316 by_alias: bool = False,
317 exclude_unset: bool = False,
318 exclude_defaults: bool = False,
319 exclude_none: bool = False,
320 round_trip: bool = False,
321 warnings: bool | Literal["none", "warn", "error"] = True,
322 context: dict[str, Any] | None = None,
323 serialize_as_any: bool = False,
324 ) -> str:
325 """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json
326
327 Generates a JSON representation of the model using Pydantic's `to_json` method.
328
329 Args:
330 indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
331 include: Field(s) to include in the JSON output. Can take either a string or set of strings.
332 exclude: Field(s) to exclude from the JSON output. Can take either a string or set of strings.
333 by_alias: Whether to serialize using field aliases.
334 exclude_unset: Whether to exclude fields that have not been explicitly set.
335 exclude_defaults: Whether to exclude fields that have the default value.
336 exclude_none: Whether to exclude fields that have a value of `None`.
337 round_trip: Whether to use serialization/deserialization between JSON and class instance.
338 warnings: Whether to show any warnings that occurred during serialization.
339
340 Returns:
341 A JSON string representation of the model.
342 """
343 if round_trip != False:
344 raise ValueError("round_trip is only supported in Pydantic v2")
345 if warnings != True:
346 raise ValueError("warnings is only supported in Pydantic v2")
347 if context is not None:
348 raise ValueError("context is only supported in Pydantic v2")
349 if serialize_as_any != False:
350 raise ValueError("serialize_as_any is only supported in Pydantic v2")
351 return super().json( # type: ignore[reportDeprecated]
352 indent=indent,
353 include=include,
354 exclude=exclude,
355 by_alias=by_alias,
356 exclude_unset=exclude_unset,
357 exclude_defaults=exclude_defaults,
358 exclude_none=exclude_none,
359 )
360
361
362def _construct_field(value: object, field: FieldInfo, key: str) -> object:

Callers 3

to_jsonMethod · 0.95
model_jsonFunction · 0.80

Calls 1

jsonMethod · 0.45