in src/fmeval/data_loaders/json_parser.py [0:0]
def _parse_column(args: ColumnParseArguments) -> Optional[Union[Any, List[Any]]]:
"""Parses a single column, specified by `args`, from a dataset
and converts the contents of the column to strings if needed.
:param args: See ColumnParseArgs docstring.
:returns: If search_jmespath returns None, this function returns None.
Otherwise, If `args.dataset_mime_type` is MIME_TYPE_JSON, then the return value
is a list representing the parsed column. This list is always a 1D array.
If MIME_TYPE_JSON_LINES, then the dataset being parsed is assumed to be
a single JSON Lines row, in which case the return value is a single scalar
value representing the sole value in the "column".
"""
result = search_jmespath(
jmespath_parser=args.jmespath_parser,
jmespath_query_type=args.column.value.name,
dataset=args.dataset,
dataset_name=args.dataset_name,
)
if result is not None:
JsonParser._validate_jmespath_result(result, args)
if args.column.value.should_cast:
result = JsonParser._cast_to_string(result, args)
return result