Java is not JavaScript. Totally different. So if you are reading up on Java, you are wasting your time.
So ignoring the environment variables for a second, you are essentially saying...
msg["payload.Volts"] = "123456";
return msg;
Which will correctly set a property in msg
named payload.Volts
- as you are getting.
If you want nested objects e.g. a Volts
property inside an object named payload
inside the msg
object you will have to approach this differently.