My PHP script specs.php outputs the following:
{ \"hd\": { \"dimensions\": [ \"1920x1080\", \"1920x1080\", \"
You can't use a variable in the dot notation, but you can use brackets notation:
var size = specs_obj[preset].sizes[0];
If preset contains the string "medium", that's functionally identical to:
preset
var size = specs_obj.medium.sizes[0];