def reduce_json_array(j):
    """Recursively go over a JSON and unpack arrays which have only one item,
    i.e. remove unnecessary arrays (brackets).

    Args:
        j (list of dict): A JSON to be reduced.

    Returns:
        list or dict: a reduced JSON with unnecessary array removed.
    """

    if isinstance(j, list):
        if len(j) == 1:
            reduced = reduce_json_array(j[0])
        else:
            reduced = [reduce_json_array(e) for e in j]
    elif isinstance(j, dict):
        reduced = {k: reduce_json_array(v) for k, v in j.items()}
    else:
        reduced = j
    return reduced