{"id":5899,"library":"dictor","title":"dictor: An Elegant Dictionary and JSON Handler","description":"Dictor is a Python JSON and Dictionary (Hash, Map) handler. It takes a dictionary or JSON data and returns a value for a specific key, simplifying access to deeply nested structures. Its primary goal is to eliminate the need for repetitive `try/except` blocks when performing lookups and to provide flexible fallback values for missing keys. The current version is 0.1.12, with new releases typically driven by feature additions or bug fixes rather than a strict cadence.","status":"active","version":"0.1.12","language":"python","source_language":"en","source_url":"https://github.com/perfecto25/dictor","tags":["dictionary","json","handler","nested data","data access","utility"],"install":[{"cmd":"pip install dictor","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"dictor","correct":"from dictor import dictor"}],"quickstart":{"code":"import json\nfrom dictor import dictor\n\ndata = {\n    \"characters\": {\n        \"Lonestar\": {\n            \"id\": 55923,\n            \"role\": \"renegade\",\n            \"items\": [\"space winnebago\", \"leather jacket\"]\n        },\n        \"Barfolomew\": {\n            \"id\": 55924,\n            \"role\": \"mawg\",\n            \"items\": [\"peanut butter jar\", \"waggy tail\"]\n        }\n    }\n}\n\n# Accessing a nested value using dot notation\nlonestar_role = dictor(data, \"characters.Lonestar.role\")\nprint(f\"Lonestar's role: {lonestar_role}\")\n\n# Accessing a non-existent key with a fallback default value\ndark_helmet_role = dictor(data, \"characters.Dark Helmet.role\", default=\"villain\")\nprint(f\"Dark Helmet's role: {dark_helmet_role}\")\n\n# Accessing an item from a list by index\nfirst_lonestar_item = dictor(data, \"characters.Lonestar.items.0\")\nprint(f\"First item for Lonestar: {first_lonestar_item}\")\n","lang":"python","description":"This example demonstrates basic usage of `dictor` to safely retrieve nested values from a dictionary using dot notation, providing a default value for non-existent keys, and accessing elements within lists."},"warnings":[{"fix":"If currently using Python 2, either upgrade your project to Python 3 or explicitly pin the `dictor` dependency to `dictor==0.1.12` in your `requirements.txt`.","message":"Dictor versions 0.1.13 and up will drop support for Python 2. Users on Python 2 must remain on version 0.1.12 or earlier.","severity":"breaking","affected_versions":">=0.1.13"},{"fix":"Use the `pathsep` argument to specify a different character for path separation (e.g., `dictor(data, 'my.key', pathsep='_')`) or ensure keys with dots are not used in dot-separated search paths.","message":"If a dictionary key contains a literal dot ('.') character (e.g., `'my.key'`), `dictor` will by default interpret it as a path separator, potentially leading to `None` or an incorrect value. For example, `dictor({'my.key': 'value'}, 'my.key')` will return `None` because it tries to find a nested `key` within `my`.","severity":"gotcha","affected_versions":"all"},{"fix":"Only use `checknone=True` when `None` is explicitly considered an invalid value for the path, and you intend for a `ValueError` to be raised. Otherwise, rely on the default behavior where `None` is returned, or provide a `default` fallback value.","message":"When `checknone=True` is passed to `dictor`, it will raise a `ValueError` if the value found at the specified path is `None`. This can lead to unexpected program termination if `None` is a valid intermediate value.","severity":"gotcha","affected_versions":"all"},{"fix":"Be aware that `rtype` does not enforce type conversion for complex data structures; manual casting or further processing may be required if a specific type for these is desired.","message":"The `rtype` argument, used to cast the return value to a specific type (e.g., `int`, `str`), only applies to scalar values. If the value found at the specified path is a complex data structure (like a dictionary, list, or tuple), it will be returned as is, regardless of the `rtype` specified.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.1.12':67 'access':34,90 'addit':75 'block':50 'bug':77 'cadenc':83 'current':64 'data':24,88,89 'deepli':36 'dictionari':4,14,21,84 'dictor':1,8 'driven':72 'eleg':3 'elimin':44 'fallback':58 'featur':74 'fix':78 'flexibl':57 'goal':41 'handler':7,17,86 'hash':15 'json':6,12,23,85 'key':32,62 'lookup':53 'map':16 'miss':61 'need':46 'nest':37,87 'new':69 'perform':52 'primari':40 'provid':56 'python':11 'rather':79 'releas':70 'repetit':48 'return':26 'simplifi':33 'specif':31 'strict':82 'structur':38 'take':19 'try/except':49 'typic':71 'util':91 'valu':28,59 'version':65","created_at":"2026-04-14T18:33:16.648613+00:00","updated_at":"2026-04-16T06:22:30.500441+00:00","problems":[{"fix":"If `None` is an acceptable value for the path, remove `checknone=True` from the `dictor` call. Alternatively, ensure the data at the specified path is not `None` or provide a `default` fallback value to `dictor`.","cause":"The `dictor` function was called with the `checknone=True` argument, and the value found at the specified path in the dictionary or JSON data was `None`.","error":"ValueError"},{"fix":"If the `dictor` call is expected to return a list, access its elements using list indexing (e.g., `my_list[0]`) or iterate over it. If a dictionary *within* the list is intended, adjust the path in `dictor` or perform list indexing before making another `dictor` call or using dictionary methods.","cause":"The `dictor` function returned a list because the specified path pointed to a list, but the user then attempted to use the `.get()` method, which is a dictionary-specific method, on the returned list object.","error":"AttributeError: 'list' object has no attribute 'get'"},{"fix":"If your dictionary keys contain literal dots, use the `pathsep` argument in `dictor` to specify a different character for path separation (e.g., `dictor(data, 'my.key', pathsep='_')`) or ensure such keys are not used in dot-separated search paths.","cause":"This error typically occurs when a dictionary key contains a literal dot ('.'), which `dictor` by default interprets as a path separator. This leads `dictor` to search for a non-existent nested structure and return `None`, and a subsequent operation attempts to call a method or access an attribute on this `None` object.","error":"AttributeError: 'NoneType' object has no attribute 'some_method'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.1.12","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/perfecto25/dictor","docs":null,"changelog":null,"pypi":"https://pypi.org/project/dictor/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}