有一个JSON格式的变量userinfovaruserinfo={"USERNAME":"","EMAIL":"","SALT":"","HASH":"","DEVICEID":"","TOKIN":""};然后还有一个字符串变量data的内容{"USERNAME":"abc","EMAIL":"xxx@gmail.com","SALT":"b9L7RqfCAIeJ72R1q8pqru3ZyZJJ6VCpyV/YBdIjMDbnGx5UwtnO7+883Q0e2kSoji25/L4NK4ZSebrBYjBifdd7Jn9VJDDLYu0sA76LgmMGswp6zzAEosFa3AHMUh0lNStf+8K3OhvPA1ER3IfjJN0Y33u14cYdLxGshCinT4I=","HASH":"+b5cNtArzhKJAZEegaIE/DtTRC+dRP0bjydOhGiyJptMYoTw9pPyjIKpZWMGNp9PK7MI1TKidq03wCr3jFeAisP2nMXRmsZFmhTLhzgtrGsxFomz0cZiEtqqSNiBkXiPtr/V7mwgiXqFbxf3om17CP9diR+1enjY2Br6zBoaq8A=","DEVICEID":"","TOKIN":"25230B4D629F59876948C2A3BA2A33E8"}我想把data的内容放到userinfo的对应位置上,该怎么做?data里面的内容是之前把这个userinfo保存成的字符串。或者换句话说我现在想用USERNAME字段的内容,改怎么用呢?
2 回答
翻翻过去那场雪
TA贡献2065条经验 获得超13个赞
for(xinuserinfo){if(data[x]){userinfo[x]=data[x];}}console.log(userinfo['USERNAME']);是这样的么?
添加回答
举报
0/150
提交
取消