无法从钛中的json对象中删除数据

时间:2011-10-11 07:44:36

标签: javascript android json titanium-mobile

我正在使用Titanium开发Android应用程序。我想删除并将一些新数据推送到json对象。我使用以下代码:

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

我的json对象给出了以下内容:

{"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}}
]
}

我想删除jsontext.feeds [0]。我尝试像 jsontext.feeds.splice(0,1)之类的Splice它返回正确的值,但它实际上没有从jsontext中删除任何值。有没有办法从json对象中删除数据或任何关于我的建议code.Thank你。

1 个答案:

答案 0 :(得分:0)

尝试使用shift()

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

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

alert(jsontext.feeds[0].username) //bcd  ?