title: How to reference the key from json with node.js
body: <p>How would I access the following json data</p>
  
  <pre><code>"users":{
      "2211392761":{"username":"user1"},
      "14300995184":{"username":"user2"},
      "2781554712":{"username":"user3"},
      "3554341":{"username":"user4"},
      "202611":{"username":"user5"},
      "17754300653761":{"username":"user6"}
  }
  </code></pre>
  
  <p>I have this so far and I am aware it is completely wrong:</p>
  
  <pre><code>Object.keys(jsonevents["events"]).forEach(function(key) {
      if(eventName == jsonevents["events"][key]["name"]){
          if(jsonevents["events"][key]["users"]){
              if(jsonevents['events'][key]["users"][message.author.id]){
                  delete jsonevents['events'][key]["users"][message.author.id];
                  fs.writeFile(eventsjson, JSON.stringify(jsonevents),'utf8');
                  sayMessage += "```User is no longer part of the event "+jsonevents['events'][key]["name"]+"```";
              } else {
                  sayMessage += "```user is not in the event "+jsonevents['events'][key]["name"]+"```";
              }
          } else {
              sayMessage += "```Why do we have no users```";
          }
      } else {
          //sayMessage += "```No event found```";
      }
  });
  </code></pre>
  
  <p>I need to be able to access the key by passing in the username, so <code>user2</code> would give me <code>14300995184</code> so i can then use this to remove the user from the event.</p>