怎么按照这个json格式只改第一个第二个第五个 往下写呀铁铁们
{
"id": 58001,
"dressID": 101,
"sex": 2,
"type": "yifu",
"colorGroup": 58001,
"color": "A6D869",
"name": "common_yifu",
"flag": "0",
"gamerFlag": "0",
"flagDesc": "0",
"beauty": 26,
"active": 1,
"weight": 100,
"npcGrade": 0
},
用什么语言?
而且问题描述不清楚,是要改id,dressID,colorGroup这三个属性吗
javascript代码:
var json = {
"id": 58001,
"dressID": 101,
"sex": 2,
"type": "yifu",
"colorGroup": 58001,
"color": "A6D869",
"name": "common_yifu",
"flag": "0",
"gamerFlag": "0",
"flagDesc": "0",
"beauty": 26,
"active": 1,
"weight": 100,
"npcGrade": 0
};
json["id"]=99999;
json["dressID"]=22222;
json["colorGroup"]=7777777;
console.log(JSON.stringify(json,null,4));
说话请说完整点。完全看不懂你在说什么
我只能回答:“先这样,再这样,最后再这样就搞定了”
let index = 0
const obj = {
"id": 58001,
"dressID": 101,
"sex": 2,
"type": "yifu",
"colorGroup": 58001,
"color": "A6D869",
"name": "common_yifu",
"flag": "0",
"gamerFlag": "0",
"flagDesc": "0",
"beauty": 26,
"active": 1,
"weight": 100,
"npcGrade": 0
}
for(item in obj){
index++
if(index ===1){
obj[item] = 111
}
if(index ===2){
obj[item] = 222
}
if(index ===5){
obj[item] = 333
}
}
console.log(obj)
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!