1

I am developing Android application using Titanium. I want to delete and push some new data in to json object.I used following code:

var jsonfeed = this.responseText;
var jsontext = JSON.parse(jsonfeed);

My json object give below:

{"feeds":
[
   {"username":"abc","user":"abc","feed":{"description":"dss","id":660,"user_id":1}},
   {"username":"bcd","user":"bcd","feed":{"description":"dddd","id":659,"user_id":1}}
]
}

I want to delete jsontext.feeds[0]. I tried Splice like jsontext.feeds.splice(0,1) it returns correct value but it actually not deleting any value from jsontext.Is there any way to delete data from json object or any suggestion about my code.Thank you.

nilkash
  • 7,408
  • 32
  • 99
  • 176

1 Answers1

0

what about try using shift()

alert(jsontext.feeds[0].username) // abc

  // shift the beginning of the array
  jsontext.feeds.shift();

alert(jsontext.feeds[0].username) //bcd  ?
david
  • 4,218
  • 3
  • 23
  • 25
  • Thank you david for reply.I tried it but it's not working.Is there any problem in accessing json object.Because splice also not working – nilkash Oct 11 '11 at 11:13
  • i did not use `var jsontext = JSON.parse(jsonfeed);` but placed your json object inplace of `JSON.parse(jsonfeed)` pluse i only tested it windows, FF, chrome ,and IE – david Oct 11 '11 at 11:25
  • @nilkash is the json data being created localy or are you receiving it for a external server you don't have control over? im just asking if so try without json.parse – david Oct 11 '11 at 11:26
  • I am receiving json object from external server not created localy – nilkash Oct 11 '11 at 12:20
  • My server side code returning me json object which looks similar given in the question. – nilkash Oct 11 '11 at 12:33