I am trying to remove some property of a JSON response.
I would like to remove this part of the response (first part) :
{
"en" : 10,
"left" : false,
"right" : false,
"result" :
And remove too the last character of the response (last part) :
"}"
I have tried different ways to do this but none of them work as I would like them to.
var object_delete = ['en','left','right','result'];
for(i in object_delete){
var data = JSON.parse(JSON.stringify(data).replace(object_delete[i], ""));
}
I expect the output :
[ {
"type1" : "string data",
"type2" : "string data",
"type3" : {
"name" : "string data"
},
"red" : {
"path" : "string data",
"path2" : null,
"path3" : null,
"path4" : null
}
} ]
But the actual output is :
{
"en" : 2,
"left" : false,
"right" : false,
"result" : [ {
"type1" : "string data",
"type2" : "string data",
"type3" : {
"name" : "string data"
},
"red" : {
"path" : "string data",
"path2" : null,
"path3" : null,
"path4" : null
}
} ]
}
Anyone have any idea how this can be done?