{"id":20528757,"url":"https://github.com/zmap/zson","last_synced_at":"2025-05-09T11:30:44.567Z","repository":{"id":15154082,"uuid":"17881615","full_name":"zmap/zson","owner":"zmap","description":"A python library that allows easily encoding and decoding objects into JSON","archived":false,"fork":false,"pushed_at":"2015-06-30T15:54:54.000Z","size":199,"stargazers_count":7,"open_issues_count":0,"forks_count":5,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-03-26T19:08:22.401Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zmap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-18T20:54:00.000Z","updated_at":"2020-05-11T10:04:41.000Z","dependencies_parsed_at":"2022-08-29T03:31:37.413Z","dependency_job_id":null,"html_url":"https://github.com/zmap/zson","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmap%2Fzson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmap%2Fzson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmap%2Fzson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmap%2Fzson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zmap","download_url":"https://codeload.github.com/zmap/zson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224859117,"owners_count":17381656,"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":[],"created_at":"2024-11-15T23:27:03.512Z","updated_at":"2024-11-15T23:27:04.060Z","avatar_url":"https://github.com/zmap.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZSON\n\n## Installation\n\nInstall the egg as you would any other egg.\n\n```\npip install zson\n```\nor\n\n```\neasy_install zson\n```\n\n## Usage \n\nIf you want an object to be JSON decodable, you need to define a to_json instance method that returns a dict of json-encodable objects. If you want your object to be encodable, define a from_json class method that takes back that dictionary. Yes, you can do that recursively and put a json-encodable object in your dict. And that's it. You must also use a newstyle class. It's 2014... if you're not already, you're _actually_ doing something wrong. You also get free json-able datetime objects... because really, it's pretty freaking nonsensical that this doesn't work out of the box. An example is below if it would help. \n\n```python\n\nclass MyObject(object):\n\n    def __init__(self, name):\n        self._name = name\n\n    def to_json(self):\n        return {'name':self._name}\n\n    @classmethod\n    def from_json(self, obj):\n        return cls(obj[\"name\"])\n\n```\n\n## Celery Usage\n\nZson was originally written to allow objects to be passed in Celery. If you want to use zson as your serializer in Celery, you can set this by creating a configuration file and adding\n\n```\nCELERY_TASK_SERIALIZER = 'zson'\nCELERY_RESULT_SERIALIZER = 'zson'\nCELERY_ACCEPT_CONTENT = [\"zson\"]\n```\n\nand then loading this configuration file when you configure your Celery app:\n\n```python\nc = celery.Celery('zsearch', backend='amqp', broker='amqp://')\nc.config_from_object('celeryconfig')\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzmap%2Fzson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzmap%2Fzson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzmap%2Fzson/lists"}