import json
import traceback


def _read_json_with_comments(json_path):
    """Reads a file with '//' comments.
    Reads the file, removes the commented lines and return
    a json loads of the result.
    """
    file_lines = []
    with open(json_path) as json_file:
        file_lines = json_file.readlines()
    lines_without_comments = []
    for line in file_lines:
        if line.strip()[0:2] != '//' and len(line.strip()) > 0:
            lines_without_comments.append(line)
    file_content_without_comments = ''.join(lines_without_comments)
    json_data = {}
    try:
        json_data = json.loads(file_content_without_comments)
    except Exception:
        print('There was an error reading file {}'.format(json_path))
        print(traceback.format_exc())
    return json_data