<?php
namespace Engine\Mvc\Response\Components;

class DebugJsonBody extends JsonBody
{
	public function asString()
	{
		$objectExplorer = new \App\Utils\Views\ObjectExplorer(json_decode(json_encode($this->body)));

		foreach ($this->body as $key=>$x) {
			$objectExplorer->addMenuSection($key, $key);
		}

		$objectExplorer->setOption('interactive', true);
		$objectExplorer->setOption('showEmptyLeafs', false);
		$objectExplorer->setOption('collapsed', false);
		return
			$objectExplorer->preloadCss(\Engine\Theme\CSSLoader\CSSLoader::getInstance()) .
			$objectExplorer->preloadJs(\Engine\Theme\JSLoader\JSLoader::getInstance()) .
			$objectExplorer->renderHtml();
	}
}
