How to loop through JSON array?

前端 未结 8 1646
鱼传尺愫
鱼传尺愫 2020-12-01 14:52

I have some JSON-code which has multiple objects in it:

[
    {
        \"MNGR_NAME\": \"Mark\",
        \"MGR_ID\": \"M44\",
        \"EMP_ID\": \"1849\"
           


        
8条回答
  •  清歌不尽
    2020-12-01 15:32

    This will find the number of occurrences of the MNGR_NAME key in your Object Array:

    var numMngrName = 0;
    
    $.each(json, function () {
        // 'this' is the Object you are iterating over
        if (this.MNGR_NAME !== undefined) {
            numMngrName++;
        }
    });
    

提交回复
热议问题