import json
import codecs


def parse_json(filename):
    """Parse data from filename and return a list of boats."""

    country = filename.split("/")[2][0:3]

    try:
        rms = json.load(codecs.open(filename, "r", "utf-8-sig"), strict=False)
    except json.decoder.JSONDecodeError as e:
        print(f"Error parsing file: {filename}, error: {e}")
        return []

    data = rms["rms"]

    for item in data:
        item["country"] = country

    return data