English 中文(简体)
婚外价值,然后通过JSON强食
原标题:Extra values when parsing, then looping through a JSON String

因此,我有一位神职人员,我打算作同,提醒内容。

var json_string =  [1,2,3,4,5] ;
var parsed_string = JSON.parse(json_string);
for(x in parsed_string) alert(x)

然而,我不仅拿到这5个要素,而且 whole一整座外 cr,我没有要求开工......美元、家庭、 app、合伙等......。

在不打这些额外价值的情况下,我是否能够通过这一阵列加以篡改?

www.un.org/Depts/DGACM/index_french.htm 时间长将我的适当阵列长度推回了。

最佳回答

这是你使用<条码>的单一理由;用于穿透阵列。

var json_string =  [1,2,3,4,5] ;
var parsed_string = JSON.parse(json_string);
for(var i=0;i<parsed_string.length;i++) alert(parsed_string[i]);
问题回答

你应该通过 Java文,如:

for (var key in obj) {
    if (obj.hasOwnProperty(key)) {
        alert(obj[key]);
    }
}

<代码>.hasOWnProperty()确保key具体规定的财产不继承。 但是,你在此再次处理一系列问题:

for (var i = 0; i < arr.length; i++) {
    alert(arr[i]);
}




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签