{"id":17029055,"url":"https://github.com/rosscdh/drf-prettify-json_serializer-field","last_synced_at":"2026-05-09T14:02:07.867Z","repository":{"id":57424084,"uuid":"131851322","full_name":"rosscdh/drf-prettify-json_serializer-field","owner":"rosscdh","description":"You got ugly json, we got a serializer that can massage that data into something useful","archived":false,"fork":false,"pushed_at":"2019-02-18T11:57:03.000Z","size":8,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-25T17:05:21.621Z","etag":null,"topics":["djangorestframework","field","serialization"],"latest_commit_sha":null,"homepage":null,"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/rosscdh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-02T13:03:07.000Z","updated_at":"2019-02-18T11:57:04.000Z","dependencies_parsed_at":"2022-09-16T15:11:11.721Z","dependency_job_id":null,"html_url":"https://github.com/rosscdh/drf-prettify-json_serializer-field","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rosscdh/drf-prettify-json_serializer-field","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosscdh%2Fdrf-prettify-json_serializer-field","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosscdh%2Fdrf-prettify-json_serializer-field/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosscdh%2Fdrf-prettify-json_serializer-field/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosscdh%2Fdrf-prettify-json_serializer-field/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rosscdh","download_url":"https://codeload.github.com/rosscdh/drf-prettify-json_serializer-field/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosscdh%2Fdrf-prettify-json_serializer-field/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259971331,"owners_count":22940009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["djangorestframework","field","serialization"],"created_at":"2024-10-14T07:57:23.822Z","updated_at":"2026-05-09T14:02:02.827Z","avatar_url":"https://github.com/rosscdh.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# drf-prettify-json-serializer\n\n*You got ugly json, we got a serializer that can massage that data into something useful*\n\nSometimes you get \"*json*\", that you have NO control over and the json is ugly. I mean really Ugly and Inconsistant. \n\nSo, being the control-freak that you are you decide to bring order to the chaos, but for some reason DRF does not allow data massaging. Which is a pity as its a a damned fine presenter pattern implementation but lacks this tiny bit of functionality.\n\nso if source is defined it will read that from the provided json data.\n\n**NB** this field class is for serialization of json data only.\n\n## Installation\n\n```sh\npip install drf-prettify-json-serializer-field\n```\n\n## About\n\nFor example:\n\n```\n#\n# argh! my eyes... dear lord! are we enterprise or what?\n#\n{\n    \"customerID\": \"123\",                     # lowercase uppercase\n    \"CustomerUID\": \"abc456\",                 # CamelUpper\n    \"CustomerEmail\": \"bob@example.com\",      # CamelCase\n    \"KundenKarteNr\": \"Ad0ek344\",             # This is not a number and its not english\n    \"CardType\": 1,                           # this one is ok, but CamelCase\n    \"Filial\": \"3\",                           # not english and ugly\n}\n```\n\nis brought under control like so:\n\n```\nimport drf_prettify_json_serializer_field.fields  as json_source_fields\n\n\nclass CustomerSerializer(serializers.Serializer):\n    customer_id = json_source_fields.IntegerField(source='customerID')\n    customer_uid = json_source_fields.CharField(source='CustomerUID', allow_null=True)\n    email = json_source_fields.EmailField(source='CustomerEmail', allow_null=True)\n    card = json_source_fields.CharField(source='KundenKarteNr')\n    card_type = json_source_fields.IntegerField(source='CardType')\n    store = json_source_fields.IntegerField(source='Sill.Seperator.Deepnested.Filial')\n\n#\n# ahh better\n#\n{\n    \"customer_id\": 123,\n    \"customer_uid\": \"abc456\",\n    \"email\": \"bob@example.com\",\n    \"card\": \"Ad0ek344\",\n    \"card_type\": 1,\n    \"store\": 3,\n}\n```\n\nAnd to add fields you simply\n\n```\nclass ExistingField(PrettifyDataFromJsonField, serializers.ExistingField):\n    pass\n```\n\n## TODO\n\n1. tests\n2. ~deep nested key references (dot seperated)~\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frosscdh%2Fdrf-prettify-json_serializer-field","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frosscdh%2Fdrf-prettify-json_serializer-field","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frosscdh%2Fdrf-prettify-json_serializer-field/lists"}