Error reading variables in 'variables.json': json: cannot unmarshal object into Go value of type string

Variables.json file

{

"variables": {    

"vsphere-server": "myvCenter",

"vsphere-user": "rk@example.com",

"vsphere-password": "passw0rd",

"vsphere-datacenter": "My Datacenter",    

"vsphere-cluster": "My Cluster",    

"vsphere-network": "VM Net XXX",

"vsphere-datastore": "vsphere_datastore",        

"vm-name": "testvm1",

"vm-cpu-num": "1",

"vm-mem-size": "1024",

"vm-disk-size": "40960",    

"iso_paths": "path/of/iso/rhel-server-7.8-x86_64-dvd.iso"  

}

}

I’m pretty sure it’s your “vm-cpu-num”: “1”. It wants an integer, not a string literal. So change it to be “vm-cpu-num”: 1

How is your packer build command? Could you share it with us, please?

You may try python -m json.tool variables.json to do a short validation and see the outcome.