您的JSON是不是數組:
{
"0": {
"id": 34,
"description": "A collection of in houses",
"default_branch": "master",
"tag_list": [],
"created_at": "2017-02-28T15:02:49.756+13:00",
"last_activity_at": "2017-06-09T17:49:49.975+12:00",
"shared_runners_enabled": true,
"lfs_enabled": true,
"creator_id": 13,
"namespace": {
"id": 99,
"parent_id": 98
},
"star_count": 0,
"forks_count": 0,
"open_issues_count": 0,
"public_builds": true,
"shared_with_groups": [],
"only_allow_merge_if_build_succeeds": false,
"request_access_enabled": false,
"only_allow_merge_if_all_discussions_are_resolved": false,
"permissions": {
"project_access": null,
"group_access": {
"access_level": 40,
"notification_level": 3
}
}
},
"1": {
"id": 38,
"description": "Scripts",
"default_branch": "master",
"tag_list": [],
"created_at": "2017-02-28T15:05:40.505+13:00",
"last_activity_at": "2017-07-13T08:59:20.023+12:00",
"shared_runners_enabled": true,
"lfs_enabled": true,
"creator_id": 13,
"namespace": {
"id": 99,
"parent_id": 98
},
"star_count": 0,
"forks_count": 0,
"open_issues_count": 0,
"public_builds": true,
"shared_with_groups": [],
"only_allow_merge_if_build_succeeds": false,
"request_access_enabled": false,
"only_allow_merge_if_all_discussions_are_resolved": false,
"permissions": {
"project_access": null,
"group_access": {
"access_level": 40,
"notification_level": 3
}
}
},
"2": {
"id": 49,
"description": "Dashboard",
"default_branch": "master",
"tag_list": [],
"created_at": "2017-04-26T14:50:59.051+12:00",
"last_activity_at": "2017-05-29T14:17:18.148+12:00",
"shared_runners_enabled": true,
"lfs_enabled": true,
"creator_id": 14,
"namespace": {
"id": 99,
"parent_id": 98
},
"star_count": 0,
"forks_count": 0,
"open_issues_count": 0,
"public_builds": true,
"shared_with_groups": [],
"only_allow_merge_if_build_succeeds": false,
"request_access_enabled": false,
"only_allow_merge_if_all_discussions_are_resolved": false,
"permissions": {
"project_access": null,
"group_access": {
"access_level": 40,
"notification_level": 3
}
}
},
"3": {
"id": 51,
"description": "",
"default_branch": "master",
"tag_list": [],
"created_at": "2017-05-18T16:33:48.041+12:00",
"last_activity_at": "2017-05-21T22:19:07.951+12:00",
"shared_runners_enabled": true,
"lfs_enabled": true,
"creator_id": 19,
"namespace": {
"id": 24,
"parent_id": null
},
"avatar_url": null,
"star_count": 0,
"forks_count": 0,
"open_issues_count": 0,
"public_builds": true,
"shared_with_groups": [],
"only_allow_merge_if_build_succeeds": false,
"request_access_enabled": false,
"only_allow_merge_if_all_discussions_are_resolved": false,
"permissions": {
"project_access": {
"access_level": 40,
"notification_level": 3
},
"group_access": null
}
},
"4": {
"id": 60,
"description": "",
"default_branch": "master",
"tag_list": [],
"created_at": "2017-06-09T13:59:50.464+12:00",
"last_activity_at": "2017-06-09T13:59:50.464+12:00",
"shared_runners_enabled": true,
"lfs_enabled": true,
"creator_id": 14,
"namespace": {
"id": 99,
"parent_id": 98
},
"star_count": 0,
"forks_count": 0,
"open_issues_count": 0,
"public_builds": true,
"shared_with_groups": [],
"only_allow_merge_if_build_succeeds": false,
"request_access_enabled": false,
"only_allow_merge_if_all_discussions_are_resolved": false,
"permissions": {
"project_access": null,
"group_access": {
"access_level": 40,
"notification_level": 3
}
}
},
"5": {
"id": 62,
"description": "Mattermost Android App",
"default_branch": "master",
"tag_list": [],
"created_at": "2017-06-13T08:18:30.340+12:00",
"last_activity_at": "2017-06-13T08:18:30.340+12:00",
"shared_runners_enabled": true,
"lfs_enabled": true,
"creator_id": 13,
"namespace": {
"id": 99,
"parent_id": 98
},
"star_count": 0,
"forks_count": 0,
"open_issues_count": 0,
"public_builds": true,
"shared_with_groups": [],
"only_allow_merge_if_build_succeeds": false,
"request_access_enabled": false,
"only_allow_merge_if_all_discussions_are_resolved": false,
"permissions": {
"project_access": null,
"group_access": {
"access_level": 40,
"notification_level": 3
}
}
},
"6": {
"id": 283,
"description": "",
"default_branch": null,
"tag_list": [],
"created_at": "2017-07-24T16:08:01.893+12:00",
"last_activity_at": "2017-07-27T12:41:17.423+12:00",
"shared_runners_enabled": true,
"lfs_enabled": false,
"creator_id": 23,
"namespace": {
"id": 99,
"parent_id": 98
},
"star_count": 0,
"forks_count": 0,
"open_issues_count": 1,
"public_builds": true,
"shared_with_groups": [],
"only_allow_merge_if_build_succeeds": false,
"request_access_enabled": false,
"only_allow_merge_if_all_discussions_are_resolved": false,
"permissions": {
"project_access": null,
"group_access": {
"access_level": 40,
"notification_level": 3
}
}
},
"pages": "1"
}
這是發生在有這種情況發生是數字串幾個屬性的對象,再加上一個屬性名爲'網頁'。 $.each()
通過地圖的所有鍵,包括「頁」循環。
途徑SOVE問題是:
- 您可以生成一個不太混亂JSON,這將節省你從未來的頭痛;
- 你可以事先篩選鍵,選擇只有數字的人;
- ,你可以,也許,裏面
each()
檢查如果該鍵是一個字符串;
- 另一種選擇,前面已經提到別人,會跳過沒有你所需要的關鍵的對象。
它可以是API的有板有眼「未定義」回來了?似乎你的代碼沒有問題,但當日期提交到數據庫時可能出現錯誤? – Maartje