/*
Return JSON response of uploaded videos
@return json
975032
public function getUploads($maxResults=50)
	{
		$channelsResponse = $this->youtube->channels->listChannels('contentDetails', array(
			'mine' => 'true',
		));

		foreach ($channelsResponse['items'] as $channel)
		{
			$uploadsListId = $channel['contentDetails']['relatedPlaylists']['uploads'];

			$playlistItemsResponse = $this->youtube->playlistItems->listPlaylistItems('snippet', array(
																									'playlistId' => $uploadsListId,
																									'maxResults' => $maxResults
																								));

			$items = [];
			foreach ($playlistItemsResponse['items'] as $playlistItem) 
			{
				$video = [];
				$video['videoId'] 		= $playlistItem['snippet']['resourceId']['videoId'];
				$video['title'] 		= $playlistItem['snippet']['title'];
				$video['publishedAt'] 	= $playlistItem['snippet']['publishedAt'];

				array_push($items, $video);
			}
		}

		return $items;
	}
1098956
public function jsonSerialize()
    {
        ob_start();
        echo $this->renderSearchField();
        $field = ob_get_contents();
        ob_end_clean();

        $ag = ResponseAssetGroup::get();
        $assetsResponse = [];
        foreach ($ag->getAssetsToOutput() as $position => $assets) {
            foreach ($assets as $asset) {
                if (is_object($asset)) {
                    $assetsResponse[$asset->getAssetType()][] = $asset->getAssetURL();
                }
            }
        }

        return [
            'key' => $this->getKey(),
            'label' => $this->getDisplayName(),
            'element' => $field,
            'data' => $this->data,
            'assets' => $assetsResponse,
        ];
    }
6155
protected function buildJSON()
    {
        $json = $this->parent->createFileJson($this->file);
        $json['created'] = $this->file->obj('Created')->FormatFromSettings();
        $json['lastEdited'] = $this->file->obj('LastEdited')->FormatFromSettings();
        $json['url'] = $this->file->getAbsoluteURL();

        $json['size'] = $this->file->getSize();
        $json['folder'] = $this->file->Parent()->Filename;

        if ($this->file instanceof Image) {
            $preview = $this->file->Fill(400, 133);
            $detail = $this->file->getKickAssetsDetailImage();
            $json['previewImage'] = $preview ? $preview->URL : $this->file->getPreviewThumbnail(128, 128)->URL;
            $json['detailImage'] = $detail ? $detail->URL : $this->file->getPreviewThumbnail(128, 128)->URL;
        }

        return $json;
    }
595809
public function jsonSerialize()
    {
        $response = [];
        $response['displayMenu'] = $this->collection->displayMenu();
        $response['entries'] = [];
        $response['entryGroups'] = [];
        foreach ($this->collection->getEntries() as $entry) {
            $formatter = new EntryJsonFormatter($entry);
            $response['entries'][] = $formatter->jsonSerialize();
        }
        foreach ($this->collection->getEntryGroups() as $group) {
            $formatter = new GroupJsonFormatter($group);
            $response['entryGroups'][] = $formatter->jsonSerialize();
        }

        return $response;
    }
351385
public function uploadAction()
    {
        if (!$filename = $this->get('vince_type.manager.redactor')->uploadFile()) {
            return new JsonResponse(array(
                    'error' => $this->get('translator')->trans('redactor.messages.fileUploadError', array(), 'Vince'),
                )
            );
        }

        return new Response(json_encode(array(
            'filelink' => $filename,
            'filename' => pathinfo($filename, PATHINFO_FILENAME),
            ), JSON_UNESCAPED_SLASHES), 200, array(
                'Content-Type' => 'application/json',
            )
        );
    }
1324983
public function toJson()
    {
        $json = null;
        if (!empty($this->toArray())) {
            $json = json_encode($this->toArray());
        }

        return $json;
    }
81903
function () {

			var images = {};
			var blobs = {};

			if ( 'Video' in fbxTree.Objects ) {

				var videoNodes = fbxTree.Objects.Video;

				for ( var nodeID in videoNodes ) {

					var videoNode = videoNodes[ nodeID ];

					var id = parseInt( nodeID );

					images[ id ] = videoNode.RelativeFilename || videoNode.Filename;

					// raw image data is in videoNode.Content
					if ( 'Content' in videoNode ) {

						var arrayBufferContent = ( videoNode.Content instanceof ArrayBuffer ) && ( videoNode.Content.byteLength > 0 );
						var base64Content = ( typeof videoNode.Content === 'string' ) && ( videoNode.Content !== '' );

						if ( arrayBufferContent || base64Content ) {

							var image = this.parseImage( videoNodes[ nodeID ] );

							blobs[ videoNode.RelativeFilename || videoNode.Filename ] = image;

						}

					}

				}

			}

			for ( var id in images ) {

				var filename = images[ id ];

				if ( blobs[ filename ] !== undefined ) images[ id ] = blobs[ filename ];
				else images[ id ] = images[ id ].split( '\\' ).pop();

			}

			return images;

		}
86129
public function getVerboseResponse() 
    {
        $this->execute();
        
        if ($this->error) {
            return $this->error;
        }
        
        $contentType = $this->getContentType();
        
        $body = ($this->def['dataType'] == 'array' || strpos($contentType, 'json') !== false) ? static::data2json($this->responseText) : $this->responseText;
        
        return [
            'status'    => $this->status,
            'body'      => $body, 
            'info'      => $this->responseInfo,
            'header'    => $this->responseHeaders,
            'request_header'    => $this->getRequestHeaders(),
            'content_type'      => $contentType
        ];
    }
1160410
protected function _getJson()
    {
        if ($this->_json) {
            return $this->_json;
        }

        return $this->_json = json_decode($this->_getBody(), true);
    }
618626
public function info(): JsonResponse
    {
        $data = $this->definitionService->generate(OpenApi3Generator::FORMAT);

        return $this->json($data);
    }
482599
public function jsonSerialize()
    {
        $data = [];

        if ($this->provider->includeMenuInResponse()) {
            $collection = $this->provider->getTreeCollection($this->provider->getRequestedSiteTree());
            $formatter = new TreeCollectionJsonFormatter($collection);
            $data['trees'] = $formatter;
            $data['children'] = $this->provider->getRequestedNodes();
            $siteTree = $this->provider->getRequestedSiteTree();
            $data['homeCID'] = $siteTree === null ? null : ((int) $siteTree->getSiteHomePageID() ?: null);
        } else {
            return $this->provider->getRequestedNodes();
        }

        return $data;
    }
1226602
private function getLastJsonResponse(): stdClass
    {
        if (null === ($decoded = json_decode($this->restContext->getMink()->getSession()->getDriver()->getContent()))) {
            throw new \RuntimeException('JSON response seems to be invalid');
        }

        return $decoded;
    }
981361
public function toJson()
    {
        array_walk_recursive($this->params, function (&$value) {
            $value = (string) $value;
        });
        return json_encode($this->params);
    }
108155
public function json() {
			$json = parent::json();

			$is_contact_visible = $this->fs->is_page_visible( 'contact' );
			$is_support_visible = $this->fs->is_page_visible( 'support' );

			$json['theme_title'] = $this->fs->get_plugin_name();

			if ( $is_contact_visible && $is_support_visible ) {
				$json['theme_title'] .= ' ' . $this->fs->get_text_inline( 'Support', 'support' );
			}

			if ( $is_contact_visible ) {
				$json['contact'] = array(
					'label' => $this->fs->get_text_inline( 'Contact Us', 'contact-us' ),
					'url'   => $this->fs->contact_url(),
				);
			}

			if ( $is_support_visible ) {
				$json['support'] = array(
					'label' => $this->fs->get_text_inline( 'Support Forum', 'support-forum' ),
					'url'   => $this->fs->get_support_forum_url()
				);
			}

			return $json;
		}
707622
public function fetchVideos()
    {
        try {
            $api_client = new Client();
            $list = $api_client->getVideosByArticles($this->HailID);
        } catch (\Exception $ex) {
            return;
        }

        $hailIdList = [];
        // CLean before importing
        $this->VideoGallery()->removeAll();

        foreach ($list as $hailData) {
            // Build up Hail ID list
            $hailIdList[] = $hailData['id'];

            // Check if we can find an existing item.
            $hailObj = Video::get()->filter(['HailID' => $hailData['id']])->First();
            if (!$hailObj) {
                $hailObj = new Video();
            }
            $hailObj->OrganisationID = $this->OrganisationID;
            $hailObj->HailOrgID = $this->HailOrgID;
            $hailObj->HailOrgName = $this->HailOrgName;

            $hailObj->importHailData($hailData);
            $this->VideoGallery()->add($hailObj);
        }
    }
229678
public function getJsonContent()
    {
        if ($this->jsonContent === null) {
            try {
                if (($content = $this->content) === '') {
                    return $this->jsonContent = false;
                }

                $this->jsonContent = json_decode($content, true);
            } catch (\Exception $exception) {
                return $this->jsonContent = false;
            }
        }

        return $this->jsonContent;
    }
1330794
public function wantsJson()
    {
        $acceptable = $this->getAcceptableContentTypes();
        return (isset($acceptable[0]) && (strpos($acceptable[0], '/json') !== false || strpos($acceptable[0], '+json') !== false));
    }