How to delete one element from the JSON Array

Today I founded , ‘how to delete one particular element from the JSON Array Object by specifying its index’ .


var mycomments = {'comments': [ { 'title':'one','description':'This is first comment','commentby':'arulalan'},{'title':'two','description':'This is second comment','commentby':'shrini'},{'title':'three','description':'This is thrid comment','commentby':'suresh'},{'title':'four','description':'This is fourth comment','commentby':'thayub'}, {'title':'five','description':'This is fivth comment','commentby':'baskar'},{'title':'six','description':'This is sixth comment','commentby':'ranjith'},{'title':'seven','description':'This is seventh comment','commentby':'niranjan'},{'title':'eight','description':'This is eighth comment','commentby':'antano'},{'title':'nine','description':'This is nineth comment','commentby':'solar'},{'title':'ten','description':'This is tenth comment','commentby':'john'} ] } ;

// now we are going to remove the 5 th element from our 'mycomments' json object by using "splice" in Java Script.

mycomments.comments.splice(5,1);

// array.splice( index, 1); is the syntax to remove one particular element from the array in js.

Regards,
Arulalan.T

About these ads
This entry was posted in Web. Bookmark the permalink.

3 Responses to How to delete one element from the JSON Array

  1. luislugo says:

    Thank you, this was really helpfull

    Like

  2. Pingback: 2010 in review of my blog from WP team :-) WoW | Tux Coder

  3. Pingback: Iphone Ipad Blog » Can I Retrieve Deleted Photos From My iPhone? – Get Your Lost iPhone Pictures Back!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s