Helper functions to work with nested JSON structures.
 module-attribute  ¶
 JSONTree: TypeAlias = (
    dict[str, "JSONTree[_T]"]
    | list["JSONTree[_T]"]
    | tuple["JSONTree[_T]", ...]
    | _T
)
A nested JSON structure where the leaves need not be JSON-serializable.
 module-attribute  ¶
 _JSONTree: TypeAlias = (
    dict[str, "JSONTree[_T]"]
    | list["JSONTree[_T]"]
    | tuple["JSONTree[_T]", ...]
    | dict[str, _T]
    | list[_T]
    | tuple[_T, ...]
    | _T
)
Same as JSONTree but with additional Union members to satisfy overloads.
 
    
  Iterate through each leaf in a nested JSON structure.
Source code in vllm/utils/jsontree.py
  
 json_map_leaves(
    func: Callable[[Tensor], Tensor],
    value: BatchedTensorInputs,
) -> BatchedTensorInputs
json_map_leaves(
    func: Callable[[_T], _U],
    value: BatchedTensorInputs | _JSONTree[_T],
) -> BatchedTensorInputs | _JSONTree[_U]
Apply a function to each leaf in a nested JSON structure.
Source code in vllm/utils/jsontree.py
  
 json_reduce_leaves(
    func: Callable[..., _T | _U],
    value: _JSONTree[_T],
    initial: _U = cast(_U, ...),
) -> _T | _U
Apply a function of two arguments cumulatively to each leaf in a nested JSON structure, from left to right, so as to reduce the sequence to a single value.