Edit: My issue is that when giving the function appendAllComments the parameter subid, when I alert subid it says for example 77 which indeed exists within the JSON object. So:
global_save_json.input == global_save_json.subid == global_save_json.77 (?) or "77"
yet it's returning undefined for whatever reason? Is this a number vs. string issue or something?
I need to select a key of the comments object and then loop through the array. 
From fresh_posts.php:
{ 
    "posts":{
        "5": {
            "id":"5",
            "image":"link.jpg",
            "submitter":"4322309",
            "views":"3"
        },
        "2": {
            "id":"2",
            "image":"link.jpg",
            "submitter":"4322309",
            "views":"5"
        }
    },
    "comments":{
        "2": [{
            "id":"1",
            "submitter":"submitter",
            "time":"2435657",
            "comment":"comment",
            "score":"10",
            "postid":"2"
        },
        {
            "id":"2",
            "submitter":"submitter",
            "time":"2435657",
            "comment":"comment",
            "score":"10",
            "postid":"2"
        }
    ],
        "5": [{
            "id":"3",
            "submitter":"submitter",
            "time":"2435657",
            "comment":"comment",
            "score":"10",
            "postid":"5"
        }]
    }
}
Initially have:
$.getJSON('fresh_posts.php',function(data){
    global_save_json = data.comments;
Now I need to use that global_save_json once again later down the track.
$('.main').on('click', '.new-comments', function(e) {
      var fullid = e.target.id;
      var subid = fullid.substring(8); // subid = number like 75
      function appendAllComments(input) {
        for (var commentList in global_save_json.input) {
          $.each(commentList, function(index, c) {
            // i need to set variables, i.e. var id = the value of "id" key in the object in the array of comments
          })
        }
      }
      appendAllComments(subid);
 })
I've tried to re-use an earlier for loop but it's not working, I'm stuck - see comment inside loop for what I'm trying to do
