Comparing an HTTP Post body in node.js to a JSON file, and if there's a match provide the details from the JSON file.
I've tried a couple of different functions, and not sure if my JSON file isn't formatted appropriately for what I need, or if there's something else that I'm missing.
I've attempted to use this function to do the checking:
function checkForValue(json, value) {
  for (lic_key in json) {
      if (typeof (json[lic_key]) === "object") {
          return checkForValue(json[lic_key], value);
      } else if (json[lic_key] === value) {
          //new requirement - return whole object. 
          console.log("here's the key:")
          console.log(json);
          return json;
      }
  }
  return false;
}
function checkForValue2(licenses, input_key) {
  licenses.forEach(function(lic_key) {
    console.log(lic_key.lic_key);
    if (lic_key.lic_key == input_key){
      console.log("We have a match!")
      return lic_key;
    };
    //console.log(lic_key)
  });
}
Here's my JSON file too.
[
  {"lic_key": "5d6d0916c810c639cced1da7",
    "meta":
      {
        "exp_date": "09/23/2019"},
        "organization": "Westar"
      },
    {
      "lic_key": "5d6d091601edbefc2c7f5af6",
      "meta":
      {
        "exp_date": "09/23/2019"}
      },
    {
      "lic_key": "5d6d0916f89d16775a54473d",
      "meta":
      {
        "exp_date": "09/23/2019"}
      },
    {
      "lic_key": "5d6d0916668f82f5b3e1a667",
      "meta":
      {
        "exp_date": "09/23/2019"}
      },
    {
      "lic_key": "5d6d0916012065c066976e5e",
      "meta":
      {
        "exp_date": "09/23/2019"}
      }
  ]
I'd like for the function to return the object where the lic_key matches the second variable passed into the functions. The first variable is the JSON object that I'm loading from a file.
 
     
    