Twig/Extension/MenuExtension.php
public function getMenuItemsJson(Collection $menuItems, $currentOwner) {

        $this->alreadySetIds = [];
        $this->position = 0;
        $this->currentOwner = $currentOwner;
        return json_encode($this->recursiveMenuItemHandling($menuItems));
    }
public function getMenuItemsJson(Collection $menuItems, $currentOwner) {

        $this->alreadySetIds = [];
        $this->position = 0;
        $this->currentOwner = $currentOwner;
        return json_encode($this->recursiveMenuItemHandling($menuItems));
    }
Create JSON compatible data for menu display
@param Collection $menuItems
@return string