{"id":22976771,"url":"https://github.com/arpitbbhayani/jsoncache","last_synced_at":"2026-05-01T14:33:35.561Z","repository":{"id":62572818,"uuid":"82327909","full_name":"arpitbbhayani/jsoncache","owner":"arpitbbhayani","description":"Easy way to manipulate JSON file for Python :running:","archived":false,"fork":false,"pushed_at":"2017-03-03T13:49:01.000Z","size":12,"stargazers_count":84,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-29T17:36:10.741Z","etag":null,"topics":["cache","json","python"],"latest_commit_sha":null,"homepage":"https://github.com/arpitbbhayani/jsoncache/wiki","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/arpitbbhayani.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":"2017-02-17T18:50:50.000Z","updated_at":"2026-01-09T19:11:08.000Z","dependencies_parsed_at":"2022-11-03T18:26:59.585Z","dependency_job_id":null,"html_url":"https://github.com/arpitbbhayani/jsoncache","commit_stats":null,"previous_names":["arpitbbhayani/json-cache"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/arpitbbhayani/jsoncache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arpitbbhayani%2Fjsoncache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arpitbbhayani%2Fjsoncache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arpitbbhayani%2Fjsoncache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arpitbbhayani%2Fjsoncache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arpitbbhayani","download_url":"https://codeload.github.com/arpitbbhayani/jsoncache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arpitbbhayani%2Fjsoncache/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32501402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cache","json","python"],"created_at":"2024-12-15T00:55:56.033Z","updated_at":"2026-05-01T14:33:35.526Z","avatar_url":"https://github.com/arpitbbhayani.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsoncache\n\n**jsoncache** is a file-based cache though which you can put and fetch\ndata; thus giving you an ability to easily update a small chunk of data in\na JSON file. In short you can use this library to manipulate any JSON file.\n\n## Motivation\nFor storing data in [bucket-list](https://github.com/arpitbbhayani/bucket-list)\nfor any external provider like Wunderlist, I used to make a lot of network\ncalls. Some of those calls were redundant. Because of these redundant calls\nthe utility became slower when any external provider is used. So I created\n**jsoncache** which can help me cache the responses of some of the API calls\nand eventually make the utility faster.\n\n## Installation\nInstalling `jsoncache` is as easy as\n\n```bash\npip install jsoncache\n```\n\n## Getting started with jsoncache\n\n```python\n\u003e\u003e\u003e from jsoncache import JSONCache\n\u003e\u003e\u003e j = JSONCache()\n\u003e\u003e\u003e j.put('name', 'firstname', 'Arpit')\n\u003e\u003e\u003e j.get('name', 'firstname')\n'Arpit'\n\u003e\u003e\u003e j.save()  # writes to the cache file\n```\n\nTo initialize a JSONCache all you have to do is create its object. The default\ncache file is `cache.json` and autosave feature is `off`. So all of your JSON\ncontent will be saved in memory in a dictionary. For more information about the\noptions of JSONCache, go through the documentation.\n\n`.put(*args)`, `.get(*args)` and `save()` are three methods exposed in\nJSONCache object which are used to put something into cache, get something\nfrom the cache and save the contents on the disk in a JSON file.\nThe last argument passed in `put` method should be the value (object) to be\nstored in cache and this object should be JSON serializable.\n\nIf something is not cache and you are trying to fetch it,\n`NotInCacheError` error is raised.\n\nMore info about `get`, `put`, `delete`, `save` and `errors` can be found in\ndocumentation [here](../../wiki).\n\n## Advantages\nNow you may say, what's new with this; I can simply use `import json`.\n\nBut hold on, there is one advantage using this library and that is syntactic sugar and convinience.\nSuppose you have to fetch firstname from json below\n\n```json\n{\n    \"home_user\": {\n        \"name\": {\n            \"firstname\": \"Arpit\"\n        }\n    }\n}\n```\nIf you use `json` module, your code wil look something like this\n```python\nname = j.get('home_user').get('name').get('firstname')\n```\n\nWith this piece of code, you have to check if key exists and if not handle exceptions\nand/or None values.\n\nWith this library you can do just this\n```python\nj.get('home_user', 'name', 'firstname')\n```\nAbove code will raise an exception if any of the key does not exist.\n\nSimilarly while putting data into JSON. You have to explicitly take care that all intermediatory\nkeys exist. But with this you can do simply this\n\n```python\nj.put('home_user', 'name', 'firstname', 'Arpit')\n```\n\n## Documentation\nA compehensive documentation can be found [here](../../wiki).\nLot of efforts have been put into this, hope you find it useful :smile:\n\n## Contribution\nIn case you loved this utility and have a great feature idea, then feel free\nto contribute . The complete utility is written in\n[Python](https://docs.python.org/). So for contributing all you need to have\nis working knowledge of Python.\n\nYou can find source code [here](https://github.com/arpitbbhayani/jsoncache).\n\nHere are some [ideas](../../wiki/Future-Features) that you may love to work on.\n\n## Issues\nPlease report any glitch, bug, error or an unhandled exception :frowning: Feel\nfree to [create one](../../issues/new).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farpitbbhayani%2Fjsoncache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farpitbbhayani%2Fjsoncache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farpitbbhayani%2Fjsoncache/lists"}