{"id":23115,"library":"json-source-map","title":"json-source-map","description":"Calculate the source map for a JSON document, mapping JSON values to their exact source locations (line, column, path). Version 1.0.5 supports Python 3.8-3.11. Low activity; last release March 2022.","status":"active","version":"1.0.5","language":"python","source_language":"en","source_url":"https://github.com/open-alchemy/json-source-map","tags":["json","source-map","location","parsing"],"install":[{"cmd":"pip install json-source-map","lang":"bash","label":"default"}],"dependencies":[],"imports":[{"note":"The main function is named `locate`, not `source_map`.","wrong":"from json_source_map import source_map","symbol":"locate","correct":"from json_source_map import locate"}],"quickstart":{"code":"import json\nfrom json_source_map import locate\n\njson_str = '{\"key\": \"value\"}'\ndata = json.loads(json_str)\nresult = locate(data, json_str)\nprint(result['key'])","lang":"python","description":"Parses a JSON string and returns source map for each key/value."},"warnings":[{"fix":"Access the source map via `result['key'].value` or iterate over original data keys.","message":"The `locate` function transforms the JSON data. The returned dict contains source map objects, not the original values. To access original values, use the keys from the input data.","severity":"gotcha","affected_versions":"all"},{"fix":"Always pass a string. For bytes, decode first: `json_str = file_obj.read().decode('utf-8')`.","message":"The `locate` function expects a JSON string as second argument. Passing a file object or bytes will raise a TypeError.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to Python 3.8+ or pin to json-source-map==1.0.2.","message":"Python 3.7 support was dropped in v1.0.3. Installing on Python 3.7 will get v1.0.2 or fail.","severity":"deprecated","affected_versions":">=1.0.3"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Read the file and pass the string: `with open('file.json') as f: json_str = f.read(); result = locate(data, json_str)`","cause":"Passing a non-string (e.g., file object) as the second argument to `locate`.","error":"TypeError: expected string or bytes-like object"},{"fix":"Each source map object has attributes: `.value`, `.key`, `.value_line`, `.value_col`, etc. Access via dot notation: `result['key'].value`.","cause":"Treating the source map object as if it holds the original value under key 'value'. The correct field is 'value' but only after calling `locate`. Ensure you are using the returned object correctly.","error":"KeyError: 'value'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}