Posts

Showing posts from October 25, 2013

CREATE-REMOVE-ADD IN JSON USING JAVASCRIPT

//CREATING JSON OBJECT         var Obj = { Languages: [] };         //ADDING ITEMS TO JSON OBJECT         Obj.Languages.push({ id: "1", Name: 'C Language' });         Obj.Languages.push({ id: "2", Name: 'C++ Language' });         Obj.Languages.push({ id: "3", Name: 'JAVA' });         Obj.Languages.push({ id: "4", Name: 'JAVASCRIPT' });         Obj.Languages.push({ id: "5", Name: 'JQUERY' });         //REMOVING ITEMS FROM JSON OBJECT         Obj.Languages.pop();         //REMOVING PARTICULAR ITEM FROM JSON OBJECT         Obj.Languages.splice(2, 1);         //ADDING NEW ITEM IN MIDDLE         //SIGNATURE OF splice(INDEX, COUNT TO DELETE FROM INDEX, JSON OBJECT TO ADD NEW ITEM)         Obj.Languages.splice(2, 0, { id: 5, Name: 'DOTNET' });