Python json dumps syntax error when appending list of dict
Question: I got two functions that return a list of dictionary and i'm trying to get
json to encode it, it works when i try doing it with my first function, but
now i'm appending second function with a syntax error of `": expected"`. I
will eventually be appending total of 7 functions that each output a list of
dict. Is there a better way of accomplishing this?

    
    
    import dmidecode
    import simplejson as json
    
    def get_bios_specs():
        BIOSdict = {}
        BIOSlist = []
        for v in dmidecode.bios().values():
            if type(v) == dict and v['dmi_type'] == 0:
                BIOSdict["Name"] = str((v['data']['Vendor']))
                BIOSdict["Description"] = str((v['data']['Vendor']))
                BIOSdict["BuildNumber"] = str((v['data']['Version']))
                BIOSdict["SoftwareElementID"] = str((v['data']['BIOS Revision']))
                BIOSdict["primaryBIOS"] = "True"
    
                BIOSlist.append(BIOSdict)
        return BIOSlist
    
    def get_board_specs():
        MOBOdict = {}
        MOBOlist = []
        for v in dmidecode.baseboard().values():
            if type(v) == dict and v['dmi_type'] == 2:
               MOBOdict["Manufacturer"] =  str(v['data']['Manufacturer'])
               MOBOdict["Model"] = str(v['data']['Product Name'])
    
               MOBOlist.append(MOBOdict)
        return MOBOlist
    
    
    def get_json_dumps():
        jsonOBJ = json
    
        #Syntax error is here, i can't use comma to continue adding more, nor + to append.
        return  jsonOBJ.dumps({'HardwareSpec':{'BIOS': get_bios_specs()},{'Motherboard': get_board_specs()}})
    


Answer: Use multiple items within your nested dictionary.

    
    
    jsonOBJ.dumps({
        'HardwareSpec': {
            'BIOS': get_bios_specs(),
            'Motherboard': get_board_specs()
         }
    })
    

And if you want multiple `BIOS` items or `Motherboard` items, just use a list.

    
    
    ...
         'HardwareSpec': {
            'BIOS': [
                get_bios_specs(),
                get_uefi_specs()
            ]
            ...
         }
    

