0
I’m trying to build a dynamic JSON.stringify.
Example:
initial value : var body = JSON.stringify({ "UserName": email });
if(input1Change != 0){
if(input1 != ""){
//incrementar o JSON.stringify
}
}else if(input2Change != 0){
if(input2 != ""){
//incrementar o JSON.stringify
}
}else if(input3Change != 0){
if(input3 != ""){
//incrementar o JSON.stringify
}
}else if(input4Change != 0){
if(input4 != ""){
//incrementar o JSON.stringify
}
}else if(input5Change != 0){
if(input5 != ""){
//incrementar o JSON.stringify
}
}else if(input6Change != 0){
if(input6 != ""){
//incrementar o JSON.stringify
}
}
Goal:
var body = JSON.stringify({ "UserName": email, "Name": input1.value, "Surname": input2.value, "DateBirth": d, "MobilePhone": input4.value });
Why not change the object itself and use the
JSON.stringify
only at the end?– Woss