猿问

Node.js中Json通过字符串赋值的问题

有一个JSON格式的变量userinfo
varuserinfo={
"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字段的内容,改怎么用呢?
UYOU
浏览 846回答 2
2回答

翻翻过去那场雪

for(xinuserinfo){if(data[x]){userinfo[x]=data[x];}}console.log(userinfo['USERNAME']);是这样的么?
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答