[RPGMV] Item detection

I would really appreciate any help on this, as I've spent all day trying to figure it out with no success. Basically, I need to have a way of coding detection of the inventory the party currently has, then detect each of the items in that inventory and post the item's icon to a window.


The difficulty I am having here is I don't know how to properly load the items.JSON file from Database and parse the lines so I can just tell it "If party has item X, then load iconIndex Y as sprite to window".


If there is another way to do this that I am just not seeing (as in, the JSON involvement isn't necessary or something), I'm all ears.
@spineraker


The JSON data isn't necessary. There is a function that returns all items the party currently has. Create an observer to monitor changes.


This is an example of an observer that will tell you if there are any changes to the items in the player inventory vs the list in the observer. Here's a link to the raw file : ObserverPattern.js ; Add code as necessary in the monitor changes method to do things like draw icons to a window.

Code:
//=============================================================================
// Observer Pattern                                                             
//=============================================================================


//This creates an observer in RPGMaker MV
//This is an example of checking whether an item exists on an observer


(function() {

  var parameters = PluginManager.parameters("ObserverPattern");
  
  function Setup() {
    'use strict';
    //Static class for monitoring items
    class ItemObserver {

      static startObserver() {
        this._itemList = [];
        this.update();
      }

      static update() {
        this.monitorUpdates();
        this.requestUpdate();
      }

      static requestUpdate() {
        requestAnimationFrame(this.update.bind(this));
      }

      static monitorUpdates() {
        if(!this.listMatch()) {
          console.log("Item List Updated");
          this.itemList = $gameParty.allItems();
        }
      }

      static listMatch() {
        if($gameParty !== null) {
          let items = $gameParty.allItems();
          for(let i = 0; i < items.length; i++) {
            if(this.itemList[i] === undefined  || this.itemList[i] !== items[i])
              return false;
          }
          return true;
        }
        return true;
      }

      static set itemList(itemList) {
        this._itemList = itemList;
      }

      static get itemList() {
        return this._itemList;
      }
    }

    //Start Observer Update Method
    ItemObserver.startObserver();
  }
  Setup(); 
})();

Original thread: https://forums.rpgmakerweb.com/threads/rpgmv-item-detection.70380/