MCPcopy
hub / github.com/pydantic/pydantic / json

Method json

pydantic/main.py:1348–1379  ·  view source on GitHub ↗
(  # noqa: D102
        self,
        *,
        include: IncEx | None = None,
        exclude: IncEx | None = None,
        by_alias: bool = False,
        exclude_unset: bool = False,
        exclude_defaults: bool = False,
        exclude_none: bool = False,
        encoder: Callable[[Any], Any] | None = PydanticUndefined,  # type: ignore[assignment]
        models_as_dict: bool = PydanticUndefined,  # type: ignore[assignment]
        **dumps_kwargs: Any,
    )

Source from the content-addressed store, hash-verified

1346
1347 @typing_extensions.deprecated('The `json` method is deprecated; use `model_dump_json` instead.', category=None)
1348 def json( # noqa: D102
1349 self,
1350 *,
1351 include: IncEx | None = None,
1352 exclude: IncEx | None = None,
1353 by_alias: bool = False,
1354 exclude_unset: bool = False,
1355 exclude_defaults: bool = False,
1356 exclude_none: bool = False,
1357 encoder: Callable[[Any], Any] | None = PydanticUndefined, # type: ignore[assignment]
1358 models_as_dict: bool = PydanticUndefined, # type: ignore[assignment]
1359 **dumps_kwargs: Any,
1360 ) -> str:
1361 warnings.warn(
1362 'The `json` method is deprecated; use `model_dump_json` instead.',
1363 category=PydanticDeprecatedSince20,
1364 stacklevel=2,
1365 )
1366 if encoder is not PydanticUndefined:
1367 raise TypeError('The `encoder` argument is no longer supported; use field serializers instead.')
1368 if models_as_dict is not PydanticUndefined:
1369 raise TypeError('The `models_as_dict` argument is no longer supported; use a model serializer instead.')
1370 if dumps_kwargs:
1371 raise TypeError('`dumps_kwargs` keyword arguments are no longer supported.')
1372 return self.model_dump_json(
1373 include=include,
1374 exclude=exclude,
1375 by_alias=by_alias,
1376 exclude_unset=exclude_unset,
1377 exclude_defaults=exclude_defaults,
1378 exclude_none=exclude_none,
1379 )
1380
1381 @classmethod
1382 @typing_extensions.deprecated('The `parse_obj` method is deprecated; use `model_validate` instead.', category=None)

Callers 15

open_pull_requestFunction · 0.45
get_notesFunction · 0.45
test_jsonFunction · 0.45
update_libFunction · 0.45
test_error_on_reprFunction · 0.45
test_error_jsonFunction · 0.45
test_error_json_cycleFunction · 0.45
test_error_json_unknownFunction · 0.45
test_error_json_locFunction · 0.45

Calls 1

model_dump_jsonMethod · 0.95