def annotations_json_to_bed(annotations_json):
    """
    Convert JSON formatted annotations to a flattened BED format (list of lists).

    Args:
        annotations_json (list of dict): JSON formatted annotations

    Returns:
        list of lists: list of entries corresponding to BED file entries with all entries as strings.

    """

    bed_entries = []

    for annotation in annotations_json:
        annotations = annotation.get('annotations')
        primers = annotation.get('primer_annotations')

        contig_name = annotation.get('contig_name')

        for feature in annotations + primers:
            start = feature.get('contig_match_start')
            end = feature.get('contig_match_end')
            type = '%s_%s' % (feature.get('gene_name'), feature.get('region_type'))

            bed_entries.append([contig_name, str(start), str(end), type])

    return bed_entries