import json

# Load the JSON data from the file
with open('data.json', 'r') as json_file:
    data = json.load(json_file)

# Access specific elements from the JSON
for item in data:
    print(f"Lamp:")
    print(f"\t Name: {item['name']}")
    print(f"\t Last Updated Date: {item['last_updated_date']}")
    print(f"\t Creation Date: {item['creation_date']}")
 
    # Access 'captures' list
    captures = item.get('captures', [])
    for capture in captures:
        print(f"\t Captures:")
        print(f"\t\t Capture Date: {capture.get('capture_date', 'N/A')}")
        
        # Access 'spectral_captures' list
        spectral_captures = capture.get('spectral_captures', [])
        for spectral_capture in spectral_captures:
            print(f"\t\t Spectral_captures:")
            print(f"\t\t\t CRI: {spectral_capture.get('cri', 'N/A')}")
            print(f"\t\t\t CCT: {spectral_capture.get('cct', 'N/A')}")
            
            # Access 'spectral_datas' list
            spectral_datas = spectral_capture.get('spectral_datas', [])
            if spectral_datas:
                print(f"\t\t\t Spectral_datas:")
                print(f"\t\t\t\t First [Wavelength, Intensity]: {spectral_datas[0]}")
                print(f"\t\t\t\t Last  [Wavelength, Intensity]: {spectral_datas[len(spectral_datas)-1]}")
            
    # Access the 'models' object
    model = item.get('models', {})

    cct = model.get('cct', 'N/A')
    voltage = model.get('voltage', 'N/A')

    #Those are json object nested, so we need to use multiple get to "dig" the object
    lamp_color = model.get('lamp_color', {}).get('name', 'N/A')
    use = model.get('use', {}).get('name', 'N/A')
    brand = model.get('brand', {}).get('name', 'N/A')
    categories = model.get('categories', {}).get('name', 'N/A')
    lamp_type = model.get('lamp_type', {}).get('name', 'N/A')

    print(f"\t Model:")
    print(f"\t\t CCT: {cct}")
    print(f"\t\t Voltage: {voltage}")
    print(f"\t\t Lamp color: {lamp_color}")
    print(f"\t\t Use: {use}")
    print(f"\t\t Brand: {brand}")
    print(f"\t\t Categories: {categories}")
    print(f"\t\t Lamp type: {lamp_type}")
    print(f"--------------------------------------------------")