Click here to Skip to main content
15,991,544 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have
myjson={"profile":[{"name":name1,"id":id1},{"name":name2,"id":id2},{"name":name3,"id":id3}]}


delete myjson.profile[1];

this will return
{"profile":[{"name":name1,"id":id1},null,{"name":name3,"id":id3}]}


however i need
{"profile":[{"name":name1,"id":id1},{"name":name3,"id":id3}]}


plz suggest something for it
Posted

1 solution

Profile is actually array in your json, so you need to use array functions.


JavaScript
myjson.profile.splice(1, 1);


where first 1 is index, second 1 - how many elements to remove (one)
 
Share this answer
 
Comments
Member 9658543 25-Jan-13 8:51am    
ok,thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900