将变量的值分配给我的对象标识符 JSON



首先,请原谅我的英语,不是很好。

我正在创建一个这样的 json 对象:

data = {UUIDDevice:
               {"Latitude": Latitude, 
                "Longitude": Longitude, 
                "Model": ModelDevice, 
                "IDDevice": UUIDDevice, 
                "Platform": PlatformDevice
               }
            };

我的问题是对象标识符:UUIDevice 不获取变量的值,只像这样放置 UUIDevice :

{ UUIDDevice: //<--Here should there be a text like: 35e620c299bc087a 
 { Latitude: '6.2720517',
   Longitude: '-75.5478177',
   Model: 'XT1033',
   IDDevice: '35e620c299bc087a',
   Platform: 'Android' 
 }
}

我正在尝试将变量作为字符串稍后应用于它 JSON.parse((,嗯,这很好用,但将对象标识符返回到引号中,所以当我尝试从我的对象中获取属性时,例如:数据。UUIDevice.Model 发生错误:"无法读取属性 'Model' "

我希望你能帮助我解决这个问题,我认为这可能是关于对象标识符中的串联,但我不知道会怎么样。

data = {}
data[UUIDDevice]=
               {"Latitude": Latitude, 
                "Longitude": Longitude, 
                "Model": ModelDevice, 
                "IDDevice": UUIDDevice, 
                "Platform": PlatformDevice
               };

最新更新