Given a set of JSON data, decode it, attach the relevant Page object and return as ArrayData

@param string $linkJson
@return ArrayData|null
160225
protected function decodeLinkData($linkJson)
    {
        if (!$linkJson || $linkJson === 'null') {
            return;
        }

        $data = ArrayData::create(json_decode($linkJson));

        // Link page, if selected
        if ($data->PageID) {
            $data->setField('Page', self::get_by_id(SiteTree::class, $data->PageID));
        }

        return $data;
    }
1236741
public function extract(array $json)
    {
        if (!$this->hasData($json)) {
            return null;
        }
        if (!$this->isCollection($json)) {
            return $this->extractOne($json, $json['data']);
        } else {
            $data = $this->extractMultiple($json);
            if ($this->isPaginated($json)) {
                return (new PaginatedEntitySet($data))
                    ->setPerPage($json['meta']['pagination']['per_page'])
                    ->setCurrentPage($json['meta']['pagination']['current_page'])
                    ->setTotal($json['meta']['pagination']['total']);
            }
            return new EntitySet($data);
        }
    }
706799
protected function queryJson( $uri )
    {
        $response = $this->getHttpClient( $uri )
                         ->send();

        if ( $response->isOk() )
        {
            $headers = $response->getHeaders();

            if ( $headers->has( 'Content-Type' ) &&
                 preg_match( '#^(application|text)/(.*\+)?json(\s*;.*)?$#',
                             $headers->get( 'Content-Type' )->getFieldValue() ) )
            {
                return Json::decode( $response->getBody(), Json::TYPE_ARRAY );
            }
        }

        return null;
    }
1120314
protected function getLink($linkData): string
    {
        $link = '';
        if (\is_array($linkData)) {
            $link = $linkData['link'] ?? '';
        } elseif (\is_string($linkData)) {
            $link = $linkData;
        }
        return $link;
    }
560268
public function jsonSerialize()
    {
        return array_filter(
            [
                'enable' => $this->getEnable(),
                'enable_text' => $this->getEnableText()
            ],
            function ($value) {
                return $value !== null;
            }
        ) ?: null;
    }
245339
public static function arr2json($data)
    {
        $json = json_encode(self::buildEnEmojiData($data), JSON_UNESCAPED_UNICODE);
        return $json === '[]' ? '{}' : $json;
    }
186328
public static function fromJson($json)
    {
        $responseData = json_decode($json, true);

        if (! $responseData) {
            return new Response(false, ['invalid-json']);
        }

        if (isset($responseData['success']) && $responseData['success'] == true) {
            return new Response(true);
        }

        if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
            return new Response(false, $responseData['error-codes']);
        }

        return new Response(false);
    }
1114709
function decodeJSON($json)
    {
        $json_response = json_decode($json);
        if ($json_response === null) {
            throw new Clientside\Exception("Unable to decode JSON response from: {$json}");
        }
        return $json_response;
    }
453305
public function rawJsonToArray($rawJson)
    {
        $responseDecoded = json_decode($rawJson, true, 10);
        $decodeError     = json_last_error_msg();
        if ($decodeError == 'No error') {
            if (array_key_exists($this->nameSpace, $responseDecoded)) {
                $responseDecoded = $responseDecoded[$this->nameSpace];
            }
        } else {
            $this->addStatusMessage('JSON Decoder: '.$decodeError, 'error');
            $this->addStatusMessage($rawJson, 'debug');
        }
        return $responseDecoded;
    }
115809
public function get($url, $data = null)
    {
        $cache_key = $this->get_key($url, $data);

        if ($json = $this->get_cache($cache_key, 'result')) {
            $result = json_decode($json, true);

            // Ensure cache_key exists in index
            $this->get_index();

            if (isset($result['$collection'])) {
                $collection = $result['$collection'];
                if (isset($this->indexes[$collection][$cache_key])) {
                    return $result;
                }
            }

            // Not found in proper index, then clear?
            foreach ($this->result_collections($result) as $collection) {
                $this->clear_indexes(array("{$collection}" => $cache_key));
            }
        }

        return null;
    }
1178951
protected function jsonDecode($json)
    {
        $content = json_decode((string) $json, true);
        $this->handleJsonError(json_last_error());
        
        return $content;
    }
815719
public function jsonSerialize()
    {
        return array_filter(
            [
                'enable' => $this->getEnable(),
                'threshold' => $this->getThreshold(),
                'post_to_url' => $this->getPostToUrl()
            ],
            function ($value) {
                return $value !== null;
            }
        ) ?: null;
    }
1161409
public function decode($data)
    {
        if (is_string($data)) {
            $this->arrayData = json_decode($data, true); // true gives us associative arrays
        }

        if (!is_string($data) || !$this->isValidJson()) {
            throw new JsonDecodingFailedException('The data provided was not proper JSON');
        }

        return $this->arrayData;
    }
149002
public function jsonSerialize()
    {
        return array_filter(
            [
                'enable' => $this->getEnable(),
                'email' => $this->getEmail()
            ],
            function ($value) {
                return $value !== null;
            }
        ) ?: null;
    }
1204624
static public function getJson($url, $data=null, $options=null)
    {
        $instance = new static('GET', $url, $data, $options);
        return $instance->toJson();
    }
1085673
public function jsonDecode($json, $assoc = false)
    {
        // if json_decode exists use that
        if (extension_loaded('json') && function_exists('json_decode')) {
            $decodedValue = json_decode($json, $assoc);
            if (!empty($decodedValue)) {
                return $decodedValue;
            }
        }

        try {
            return \Zend\Json\Decoder::decode(
                $json,
                $assoc
                    ? \Zend\Json\Json::TYPE_ARRAY
                    : \Zend\Json\Json::TYPE_OBJECT
            );
        } catch (Exception $exception) {
            // if a string is no valid json this call will throw Zend\Json\Exception\RuntimeException
            return null;
        }
    }
936461
public function getLink($pageNumber, $linkIndex)
    {

        $strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages/' . $pageNumber . '/links/' . $linkIndex;
        $signedURI = Utils::sign($strURI);
        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
        $json = json_decode($responseStream);
        return $json->Link;
    }