[Solved] Updating JSON response using Javascript


getresponse is an object, not a JSON string so you can just update the value.

var getresponse = [{"messages":[],"entity":{"id":817457,"name":"Test 1","campaignId":119602,"startDate":1528848000000,"endDate":1546300740000,"optimizationGoal":"CPM","lifetimeBudget":20.0,"audiences":[{"id":1026692,"name":"Default Audience","pmpDeals":null,"siteLists":null,"exchanges":{"include":[5,45],"exclude":[]}}],"max_bid":2.0,"daily_budget":null,"channels":["DESKTOP","MOBILE"]}}]
getresponse[0].entity.id = 999999

If it were a JSON string, you could do the following:

var decoded = JSON.parse(getresponse)
decoded[0].entity.id = 999999
var encoded = JSON.stringify(decoded)

solved Updating JSON response using Javascript