{"id":20049446,"url":"https://github.com/weaming/sanic-json","last_synced_at":"2026-04-14T07:32:30.432Z","repository":{"id":57463840,"uuid":"145959789","full_name":"weaming/sanic-json","owner":"weaming","description":" A thin wrapper on sanic web framework to help writting JSON API","archived":false,"fork":false,"pushed_at":"2019-07-17T08:21:49.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-30T16:23:48.289Z","etag":null,"topics":["api","json","sanic"],"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/weaming.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":"2018-08-24T07:45:03.000Z","updated_at":"2019-07-17T08:21:51.000Z","dependencies_parsed_at":"2022-09-05T05:30:25.839Z","dependency_job_id":null,"html_url":"https://github.com/weaming/sanic-json","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/weaming/sanic-json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fsanic-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fsanic-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fsanic-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fsanic-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weaming","download_url":"https://codeload.github.com/weaming/sanic-json/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fsanic-json/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31786798,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"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":["api","json","sanic"],"created_at":"2024-11-13T11:50:02.869Z","updated_at":"2026-04-14T07:32:30.416Z","avatar_url":"https://github.com/weaming.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sanic json\n\nA thin wrapper on sanic web framework to help writting JSON API.\n\nRecommond use [json-api](https://github.com/weaming/json-api) instead. It's a abstraction library of this library.\n\n```\npip3 install sanic-json\n```\n\n## Exmaple\n\nfile `api/random.py`\n\n```python\ndef obj_to_dict(obj):\n    if not obj or isinstance(obj, (str, int, float)):\n        return obj\n    elif isinstance(obj, list):\n        return [obj_to_dict(x) for x in obj]\n    elif isinstance(obj, dict):\n        return {k: obj_to_dict(v) for k, v in obj.items()}\n    else:\n        return {k: obj_to_dict(v) for k, v in obj.__dict__.items()}\n\n\n# the wrapper will get the args and kwargs value from the `request`\nasync def random_pohoto(req, count=10):\n    res = api.photo.random(count=count)\n    return {\"data\": obj_to_dict(res)}\n```\n\nfile `app.py`\n\n```python\nfrom sanic import Sanic\nfrom sanic_json import get_json_route\nfrom api.random import random_pohoto\n\napp = Sanic()\njson_route = get_json_route(app)\n\njson_route(\"/api/random\", random_pohoto)\n\n\nif __name__ == \"__main__\":\n    import os\n\n    debug = bool(os.getenv(\"DEBUG\"))\n    # hot reload in next release: https://github.com/channelcat/sanic/issues/168\n    app.run(host=\"0.0.0.0\", port=8000, debug=debug)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweaming%2Fsanic-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweaming%2Fsanic-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweaming%2Fsanic-json/lists"}