JSON Module¶
The JsonDictValue class is a zero-copy wrapper over a parsed DFTracer JSON
event. It is the element type yielded by
iter_json() and
read_json(). The underlying bytes are owned
by the C++ reader buffer; call JsonDictValue.to_dict() to materialize a
regular Python dict for storage beyond the iterator’s lifetime.
JsonDictValue Class¶
- class dftracer.utils.JsonDictValue¶
Bases:
_BaseNativeZero-copy wrapper over a parsed DFTracer JSON event.
Supports dict-like access:
event['name'],event['args']['ret']. Call.to_dict()to materialize a regular Python dict.
reader = TraceReader("trace.pfw.gz")
for event in reader.iter_json():
name = event["name"] # __getitem__
if "args" in event: # __contains__
ret = event["args"].get("ret") # nested dict access
owned = event.to_dict() # materialize to plain dict