gpt4 book ai didi

javascript - 如何统计 JSON 对象

转载 作者:可可西里 更新时间:2023-11-01 02:29:59 27 4
gpt4 key购买 nike

这是我的 JSON:

[
{
"id": "38",
"article_id": "16",
"news_event": "625",
"language": "en",
"channel_partner_id": "625",
"title": "Test",
"show_logo": null,
"description": "test\n\n",
"schedule": null,
"event_date": "2012-03-09 10:08:35",
"link_text": null,
"guid": null,
"timestamp": "2012-03-09 11:19:42",
"website": null,
"show_hours": null,
"page_text": null
},
{
"id": "37",
"article_id": "15",
"news_event": "625",
"language": "en",
"channel_partner_id": "625",
"title": "Test",
"show_logo": null,
"description": "test\n\n",
"schedule": null,
"event_date": "2012-03-09 10:08:35",
"link_text": null,
"guid": null,
"timestamp": "2012-03-09 11:19:39",
"website": null,
"show_hours": null,
"page_text": null
},
{
"id": "36",
"article_id": "14",
"news_event": "625",
"language": "en",
"channel_partner_id": "625",
"title": "Test",
"show_logo": null,
"description": "test\n\n",
"schedule": null,
"event_date": "2012-03-09 10:08:35",
"link_text": null,
"guid": null,
"timestamp": "2012-03-09 11:19:35",
"website": null,
"show_hours": null,
"page_text": null
},
{
"id": "35",
"article_id": "13",
"news_event": "625",
"language": "en",
"channel_partner_id": "625",
"title": "Test",
"show_logo": null,
"description": "test\n\n",
"schedule": null,
"event_date": "2012-03-09 10:08:35",
"link_text": null,
"guid": null,
"timestamp": "2012-03-09 11:19:31",
"website": null,
"show_hours": null,
"page_text": null
}
]

如何计算其中的对象数量?

最佳答案

您可以使用以下解决方案来统计 JSON 对象:

var jsonObject = {"test1":1,"test2":2};
var keyCount = Object.keys(jsonObject).length;

关于javascript - 如何统计 JSON 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9640190/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com