Description
Feature or enhancement
Proposal:
import json
def some_hook_logic(pairs: []):
# some logic here
if __name__ == '__main__':
with open('some.json', 'r') as fp:
json.load(fp, object_pairs_hook=some_hook_logic)
Currently hooks are provided to allow for some custom processing of json files. However, there is no way to obtain the index of the hooked operation. This would be especially useful for providing validation feedback on files, but there may be other benefits to providing this information to the hooks.
JSONDecoder
has a raw_decode
method on it that can be overwritten, which could be passed the index, however currently this parameter is essentially unused, and the index is available only to the scanner implementation (which can either be pure python or the _json.c module.
The proposal/feature is to add the index as a parameter to the hooks, or make it available as a part of JSONDecoder
, possibly as new index-aware hooks so as to leave existing code interoperable.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Metadata
Metadata
Assignees
Projects
Status