I want to create a JSON Object dynamically with the following format:
{
"deleteId":[1,2,3],
"pointId":[1,2,3],
"update":[
{
"what":"mission",
"id":1,
"value":"adsda"
},
{
"what":"mission",
"id":2,
"value":"sadjajks"
},
{
"what":"point",
"id":3,
"value":"asjdjh"
}
]
}
I'm getting data in my controller as shown below.
edit_vision_mission.controller('edit_vision_missionCtrl',['$scope','$http', 'getMissionDataService', function($scope, $http, getMissionDataService) {
$scope.visiontext = "Here is the content of vision";
getMissionDataService.getMissionData().success(function(response){
$scope.missions = response;
$scope.len = $scope.missions.length;
});
var jsonData = {};
jsonData.deleteId = [];
jsonData.pointId = [];
jsonData.update = [];
$scope.deletemission = function(missionid){
jsonData.deleteId.push(missionid);
alert("deleted " + jsonData.deleteId);
};
$scope.deletemissionpoints = function(missionpointid){
jsonData.pointId.push(missionpointid);
console.log(missionpointid);
alert("deleted " + jsonData.pointId);
};
$scope.updatemission = function(missionid, info){
var updateinfo = {"what" : "mission", "id" : missionid, "value" : info};
jsonData.update.push(updateinfo);
alert("updated " + jsonData.update);
};
$scope.updatemissionpoints = function(missionpointid, info){
var updateinfo = {"what" : "point", "id" : missionpointid, "value" : info};
jsonData.update.push(updateinfo);
alert("updated " + jsonData.update);
};
}]);
I'm struggling to make the JSON data of the above format, jsonData.update does not show anything in the alert.
I needed help on how to make JSON of the above format.
I also wanted to know the way to test JSON data in the front end?
Updatewith a capitalU, and in the code you have it with lowercaseu. Which is correct?