code: public function getMenuItemsJson(Collection $menuItems, $currentOwner) {
  
          $this->alreadySetIds = [];
          $this->position = 0;
          $this->currentOwner = $currentOwner;
          return json_encode($this->recursiveMenuItemHandling($menuItems));
      }
docs: Create JSON compatible data for menu display
  @param Collection $menuItems
  @return string