{"id":42119541,"url":"https://github.com/cakemanny/fastclasses-json","last_synced_at":"2026-01-26T14:31:30.438Z","repository":{"id":46117574,"uuid":"242618119","full_name":"cakemanny/fastclasses-json","owner":"cakemanny","description":"Serialize python dataclasses into JSON quickly!","archived":false,"fork":false,"pushed_at":"2025-05-05T09:15:46.000Z","size":124,"stargazers_count":30,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-26T08:16:26.024Z","etag":null,"topics":["dataclasses","fast","json","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cakemanny.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-24T01:02:33.000Z","updated_at":"2025-08-04T09:17:48.000Z","dependencies_parsed_at":"2024-02-20T22:29:47.125Z","dependency_job_id":"244c23f7-4ab8-4093-a02e-ded2befab23d","html_url":"https://github.com/cakemanny/fastclasses-json","commit_stats":{"total_commits":100,"total_committers":2,"mean_commits":50.0,"dds":"0.010000000000000009","last_synced_commit":"44b3b6957fb1841af2433d8666b88c0e835ace7c"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/cakemanny/fastclasses-json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakemanny%2Ffastclasses-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakemanny%2Ffastclasses-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakemanny%2Ffastclasses-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakemanny%2Ffastclasses-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cakemanny","download_url":"https://codeload.github.com/cakemanny/fastclasses-json/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakemanny%2Ffastclasses-json/sbom","scorecard":{"id":262378,"data":{"date":"2025-08-11","repo":{"name":"github.com/cakemanny/fastclasses-json","commit":"f9e95639688319e1cb9c340fc37476ce883d4630"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/cakemanny/fastclasses-json/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/cakemanny/fastclasses-json/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/cakemanny/fastclasses-json/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/cakemanny/fastclasses-json/test.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/publish.yml:24","Warn: pipCommand not pinned by hash: .github/workflows/publish.yml:25","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:21","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:22","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:26","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:33","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:37","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:41","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   8 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/publish.yml:9","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T11:07:32.446Z","repository_id":46117574,"created_at":"2025-08-17T11:07:32.446Z","updated_at":"2025-08-17T11:07:32.446Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28780349,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T13:55:28.044Z","status":"ssl_error","status_checked_at":"2026-01-26T13:55:26.068Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dataclasses","fast","json","python"],"created_at":"2026-01-26T14:31:30.375Z","updated_at":"2026-01-26T14:31:30.424Z","avatar_url":"https://github.com/cakemanny.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Fastclasses JSON\n================\n\n[![CI](https://github.com/cakemanny/fastclasses-json/actions/workflows/test.yml/badge.svg)](https://github.com/cakemanny/fastclasses-json/actions/workflows/test.yml?query=branch%3Amaster)\n[![PyPI](https://img.shields.io/pypi/v/fastclasses-json)](https://pypi.org/project/fastclasses-json/)\n\nInspired by [Dataclasses JSON](https://github.com/lidatong/dataclasses-json/).\nThis library attempts provide some basic functionality for encoding and\ndecoding [dataclasses](https://docs.python.org/3/library/dataclasses.html)\nwith close to hand-written performance characteristics for large datasets.\n\n```python\n\nfrom dataclasses import dataclass\nfrom fastclasses_json import dataclass_json\n\n@dataclass_json\n@dataclass\nclass SimpleExample:\n    str_field: str\n\nSimpleExample.from_dict({'str_field': 'howdy!'})\nSimpleExample.from_json('{\"str_field\": \"howdy!\"}')\n# SimpleExample(str_field='howdy!')\nSimpleExample('hi!').to_dict()\n# {'str_field': 'hi!'}\nSimpleExample('hi!').to_json()\n# '{\"str_field\":\"hi!\"}'\n\n```\n\nInstallation\n------------\n```bash\n$ pip install fastclasses-json\n```\n\nSupported Types\n---------------\n* `typing.List[T]` where `T` is also decorated with `@dataclass_json`\n* `typing.Optional[T]`\n* `typing.Optional[typing.List[T]]`\n* `typing.List[typing.Optional[T]]`\n* `typing.List[typing.List[typing.List[T]]]` etc\n* `typing.Dict[str, T]`\n* `enum.Enum` subclasses\n* `datetime.date` and `datetime.datetime` as ISO8601 format strings\n  - NB: if `python-dateutil` is installed, it will be used instead of the\n    standard library for parsing\n* `decimal.Decimal` as strings\n* `uuid.UUID` as strings\n* Mutually recursive dataclasses.\n\nany other types will just be left as is\n\n```python\nfrom __future__ import annotations\nfrom typing import Optional, List\n\n@dataclass_json\n@dataclass\nclass Russian:\n    doll: Optional[Doll]\n\n@dataclass_json\n@dataclass\nclass Doll:\n    russian: Optional[Russian]\n\nRussian.from_dict({'doll': {'russian': {'doll': None}}})\n# Russian(doll=Doll(russian=Russian(doll=None)))\nRussian(Doll(Russian(None))).to_dict()\n# {'doll': {'russian': {}}}\n\nfrom enum import Enum\n\nclass Mood(Enum):\n    HAPPY = 'json'\n    SAD = 'xml'\n\n@dataclass_json\n@dataclass\nclass ILikeEnums:\n    maybe_moods: Optional[List[Mood]]\n\n\nILikeEnums.from_dict({})  # ILikeEnums(maybe_moods=None)\nILikeEnums.from_dict({'maybe_moods': ['json']})  # ILikeEnums(maybe_moods=[Mood.HAPPY])\nILikeEnums(maybe_moods=[Mood.HAPPY]).to_dict()  # {'maybe_moods': ['json']}\n\nfrom datetime import date\n\n@dataclass_json\n@dataclass\nclass Enitnelav:\n    romantic: date\n\nEnitnelav.from_dict({'romantic': '2021-06-17'})  # Enitnelav(romantic=datetime.date(2021, 6, 17))\nEnitnelav(romantic=date(2021, 6, 17)).to_dict()  # {'romantic': '2021-06-17'}\n\nfrom decimal import Decimal\nfrom uuid import UUID\n\n@dataclass_json\n@dataclass\nclass TaxReturn:\n    number: UUID\n    to_pay: Decimal  # 😱\n\nTaxReturn.from_dict({'number': 'e10be89e-938f-4b49-b4cf-9765f2f15298', 'to_pay': '0.01'})\n# TaxReturn(number=UUID('e10be89e-938f-4b49-b4cf-9765f2f15298'), to_pay=Decimal('0.01'))\nTaxReturn(UUID('e10be89e-938f-4b49-b4cf-9765f2f15298'), Decimal('0.01')).to_dict()\n# {'number': 'e10be89e-938f-4b49-b4cf-9765f2f15298', 'to_pay': '0.01'}\n\n```\n\nwe are not a drop-in replacement for Dataclasses JSON. There are plenty of\ncases to use this in spite.\n\nConfiguration\n-------------\n\nPer-field configuration is done by including a `\"fastclasses_json\"` dict\nin the field metadata dict.\n\n* `encoder`: a function to convert a given field value when converting from\n  a `dataclass` to a `dict` or to JSON. Can be any callable.\n* `decoder`: a function to convert a given field value when converting from\n  JSON or a dict into the python `dataclass`. Can be any callable.\n* `field_name`: the name the field should be called in the JSON output.\n\n#### example\n\n```python\n@dataclass_json\n@dataclass\nclass Coach:\n    from_: str = field(metadata={\n        \"fastclasses_json\": {\n            \"field_name\": \"from\",\n            \"encoder\": lambda v: v[:5].upper(),\n        }\n    })\n    to_: str = field(metadata={\n        \"fastclasses_json\": {\n            \"field_name\": \"to\",\n            \"encoder\": lambda v: v[:5].upper(),\n        }\n    })\n\n\nCoach(\"London Victoria\", \"Amsterdam Sloterdijk\").to_dict()\n# {'from': 'LONDO', 'to': 'AMSTE'}\n```\n\n### Whole tree configuration options\n\n#### How to use other field naming conventions\n\nThe `field_name_transform` option allows tranforming field names of all\ndataclasses that are serialized / deserialized.\n\n```python\nfrom __future__ import annotations\nfrom fastclasses_json import dataclass_json\nfrom dataclasses import dataclass\n\n@dataclass_json(field_name_transform=str.upper)\n@dataclass\nclass Box:\n    dimensions: Dimensions\n    weight_in_g: int\n\n@dataclass\nclass Dimensions:\n    height_in_mm: int\n    width_in_mm: int\n    depth_in_mm: int\n\nBox(Dimensions(12, 24, 35), 944).to_dict()\n# {'DIMENSIONS': {'HEIGHT_IN_MM': 12, 'WIDTH_IN_MM': 24, 'DEPTH_IN_MM': 35}, 'WEIGHT_IN_G': 944}\n```\n\n\nType checking (i.e. using mypy)\n-------------------------------\n\nIf using type annotations in your code, you may notice type errors when type\nchecking classes that use the `@dataclass_json` decorator.\n\n```\n% mypy tests/for_type_checking.py\ntests/for_type_checking.py:27: error: \"A\" has no attribute \"to_json\"\ntests/for_type_checking.py:28: error: \"Type[A]\" has no attribute \"from_dict\"\n```\n\nThere are two techniques for overcoming this, one which is simpler but likely\nto break or be unstable between versions of python and mypy; and one which\nis a bit more work on your part.\n\n### Mypy plugin\n\nChanges in python and mypy are likely to lead to a game of cat and mouse, but\nfor the moment, we have a plugin that you can configure in your `setup.cfg`\n\n```\n% cat setup.cfg\n[mypy]\nplugins = fastclasses_json.mypy_plugin\n```\n\n### Mixin with stub methods\n\nThere is a mixin containing stub methods for converting to and from dicts and\nJSON. This can be useful if the mypy plugin breaks or if you are using a\ndifferent type checker.\n\n```python\nfrom dataclasses import dataclass\nfrom fastclasses_json import dataclass_json, JSONMixin\n\n@dataclass_json\n@dataclass\nclass SimpleTypedExample(JSONMixin):\n    what_a_lot_of_hassle_these_types_eh: str\n\nprint(SimpleTypedExample.from_dict({'what_a_lot_of_hassle_these_types_eh': 'yes'}))\n```\n```\n% mypy that_listing_above.py\nSuccess: no issues found in 1 source file\n```\n\nNotice that you have to use both the `@dataclass_json` decorator and the\n`JSONMixin` mixin. How very annoying!\n\n\nMigration \u0026 Caveats\n-------------------\n\n### `None`\nFields with the value `None` are not included in the produced JSON. This helps\nkeep the JSON nice and compact\n\n```python\nfrom dataclasses import dataclass\nfrom fastclasses_json import dataclass_json\nfrom typing import Optional\n\n@dataclass_json\n@dataclass\nclass Farm:\n    sheep: Optional[int]\n    cows: Optional[int]\n\nFarm(sheep=None, cows=1).to_json()\n# '{\"cows\":1}'\n```\n\n\n### `infer_missing`\nFastclasses JSON does not get annoyed if fields are missing when deserializing.\nMissing fields are initialized as `None`. This differs from the defaults in\n[Dataclasses JSON][dataclasses-json].\n\n```python\nfrom dataclasses import dataclass\nfrom fastclasses_json import dataclass_json\n\n@dataclass_json\n@dataclass\nclass Cupboard:\n    num_hats: int\n    num_coats: int\n\nCupboard.from_dict({'num_hats': 2})\n# Cupboard(num_hats=2, num_coats=None)\n```\n\nIn [Dataclasses JSON][dataclasses-json], there is the `infer_missing`\nparameter that gives this behaviour.\nTo make migration easier, `from_dict` and `from_json` takes the dummy parameter\n`infer_missing`, so that the following code works the same and does\nnot cause errors:\n\n```python\nCupboard.from_dict({'num_hats': 2}, infer_missing=True)\n# Cupboard(num_hats=2, num_coats=None)\n```\n\n[dataclasses-json]: https://github.com/lidatong/dataclasses-json/\n\n### `letter_case`\nFastclasses JSON does not have `letter_case`, instead see\n`field_name_transform` under [Configuration](#configuration)\nwhich can achieve the same goals.\n\n\n\u003c!-- TODO: write about nested Any? --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcakemanny%2Ffastclasses-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcakemanny%2Ffastclasses-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcakemanny%2Ffastclasses-json/lists"}