Reads the JSON file to an object or array.
@access		public
@param		bool		$asArray		Flag: read into an array
@return		object|array
@throws		RuntimeException			if parsing failed
971480
public function read( $asArray = NULL )
	{
		$json	= FS_File_Reader::load( $this->filePath );
		$data	= json_decode( $json, $asArray );
		if( json_last_error() !== JSON_ERROR_NONE ){
			$message	= 'Decoding JSON failed (%s): %s';
			$message	= vsprintf( $message, array(
				ADT_Constant::getKeyByValue( 'JSON_ERROR_', json_last_error() ),
				json_last_error_msg()
			) );
			throw new RuntimeException( $message, json_last_error() );
		}
		return $data;
	}
17866
public function getJson($asArray = false)
    {
        if ($this->isJson())
            return json_decode($this->getBody(), $asArray);
        return null;
    }
1138439
public function fetch($asArray = false)
    {
        if ($asArray) {
            $r = $this->execute();

            if ($r && $this->_with) {
                $r = $this->relationsManager->earlyLoad($this->_model, $r, $this->_with, $asArray);
            }

            return $r;
        } else {
            $modelName = get_class($this->_model);
            $r = $this->execute();
            foreach ($r as $k => $v) {
                $r[$k] = new $modelName($v);
            }

            if ($r && $this->_with) {
                $r = $this->relationsManager->earlyLoad($this->_model, $r, $this->_with, $asArray);
            }

            if ($this->_multiple === false) {
                return isset($r[0]) ? $r[0] : null;
            } else {
                return $r;
            }
        }
    }
640044
private function processJson($json)
    {
        $twee_array = json_decode($json, true);

        if (!isset($twee_array['data']) or empty($twee_array['data'])) {
            throw new RuntimeException("The provided JSON did not decode or is empty.");
        }

        foreach ($twee_array['data'] as $entity) {
            $type = $this->getTypeFromTags($entity['tags']);
            if (empty($type)) {
                $type = $this->getTypeFromTitle($entity['title']);
            }
            switch ($type) {
                case 'passage':
                    $passage = new TweePassage($entity);
                    $this->passages[$passage->title] = $passage;
                    // Set the start passage
                    if (in_array('start', $passage->tags)) {
                        $this->current_passage = $passage->title;
                        $this->history[] = $this->current_passage;
                        $this->storyline[] = $this->current_passage;
                    }
                    break;
                case 'title':
                    $this->title = $entity['text'];
                    break;
                case 'script':
                    $this->scripts[] = $entity['text'];
                    break;
                case 'stylesheet':
                    $this->stylesheets[] = $entity['text'];
                    break;
                default:
                    throw new \RuntimeException("Unknown entity type!");
            }
        }
        return true;
    }
890764
function Read($arr)
	{
		foreach (get_object_vars($this) as $prop)
		{
			if (array_key_exists($prop,$arr))
			{
				$this->$prop = $arr[$prop];
			}
		}
	}
83762
function jsonSerialize() {
		$array = $this->toArray();
		foreach (static::$_columns as $column_name => &$type) {
			if (!isset($array[$column_name])) {
				continue;
			}
			$value = &$array[$column_name];

			if ($type === Model::COLUMN_TYPE_BOOLEAN) {
				if (0 === $value) {
					$value = false;
				} elseif (1 === $value) {
					$value = true;
				}
			} else if (
				$type === Model::COLUMN_TYPE_TIMESTAMP
				|| $type === Model::COLUMN_TYPE_INTEGER_TIMESTAMP
			) {
				if (!$value) {
					$array[$column_name] = null;
					continue;
				}
				if (!is_int($value)) {
					$value = strtotime($value);
				}
				if (!is_int($value)) {
					throw new RuntimeException('Error parsing date "' . $array[$column_name] . '"');
				}
				$value = date('c', $value);
			}
		}
		return $array;
	}
1191225
public function readArray() {

            $arrId = $this->readU29();
            if (($arrId & 0x01)==0) {
                 $arrId = $arrId >> 1;
                 if ($arrId>=count($this->storedObjects)) {
                    throw new Exception('Undefined array reference: ' . $arrId);
                    return false;
                }
                return $this->storedObjects[$arrId]; 
            }
            $arrId = $arrId >> 1;
            
            $data = array();
            $this->storedObjects[] &= $data;

            $key = $this->readString();

            while($key!="") {
                $data[$key] = $this->readAMFData();
                $key = $this->readString();
            }

            for($i=0;$i<$arrId;$i++) {
                $data[] = $this->readAMFData();
            }

            return $data;

        }
1353174
private function readStoredRoutineMetadata(): void
  {
    if (file_exists($this->phpStratumMetadataFilename))
    {
      $this->phpStratumMetadata = (array)json_decode(file_get_contents($this->phpStratumMetadataFilename), true);
      if (json_last_error()!=JSON_ERROR_NONE)
      {
        throw new RuntimeException("Error decoding JSON: '%s'.", json_last_error_msg());
      }
    }
  }
820707
public static function decode($string, $asArray = false)
    {
        $decoded = self::safeDecode($string, $asArray);
        if (is_null($decoded) == false) {
            return $decoded;
        }
        $code = self::lastError();
        if ($code === JSON_ERROR_NONE) {
            return $decoded;
        }
        throw new JsonDecodeException(self::lastErrorMessage(), $code);
    }
1282967
private function readFile()
    {
        $content = @file_get_contents($this->filename);

        if (false === $content) {
            throw new InvalidArgumentException(sprintf('Cannot access "%s" to read the JSON file', $this->filename));
        }

        $content = json_decode($content, true);

        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new InvalidArgumentException(sprintf('Cannot read the JSON content: %s', json_last_error_msg()));
        }

        return \is_array($content) ? $content : [];
    }
337558
public function searchFromJson($json)
    {
        if (is_string($json)) {
            $json = yii\helpers\Json::decode($json);
        }
        if (isset($json['mainEntityClassName'], $json['searchQuery']) === false) {
            throw new \RuntimeException("mainEntityClassName and searchQuery needed to be in json for search");
        }
        $mainEntityClassName = $json['mainEntityClassName'];
        $q = new SearchQuery($mainEntityClassName, $this, $json['searchQuery']);
        $q->pagination($q->pagination);
        return $q;
    }
993296
public function json()
    {
        $json = json_decode($this->getBody(), true);
        if ($json === null) {
            throw new RuntimeException(sprintf(
                "Can't decode response as JSON: %s",
                function_exists('json_last_error_msg')?
                    json_last_error_msg():
                    'Error code '.json_last_error()
            ));
        }
        return $json;
    }
1283792
protected function asArray($data)
	{
		$array = array();

		if (is_object($data))
		{
			$data = get_object_vars($data);
		}

		foreach ($data as $k => $v)
		{
			if (is_object($v) || is_array($v))
			{
				$array[$k] = $this->asArray($v);
			}
			else
			{
				$array[$k] = $v;
			}
		}

		return $array;
	}
110059
public function fromJson(Array $jsonArray)
    {
        $classname = $this->jsonKeyToClassname(key($jsonArray));
        $jsonArray = current($jsonArray);
        if (!is_null($classname)) {
            $return = new $classname();
            if ($return instanceof ArrayObject) {
                foreach ($jsonArray as $child) {
                    $return->append($this->fromJson($child));
                }
            } else {
                $objectData = array();
                foreach ($jsonArray as $key => $child) {
                    $key = $this->keyToProperty($key);
                    if (isset($objectData[$key])) {
                        if (!is_array($objectData[$key])) {
                            $objectData[$key] = array($objectData[$key]);
                        }
                        $objectData[$key][] = $this->fromJson(array($key => $child));
                    } else {
                        $objectData[$key] = $this->fromJson(array($key => $child));
                    }
                }
                $return = new $classname($objectData);
            }
        } else {
            $return = $jsonArray;
        }

        return $return;
    }
799455
protected function read()
	{
		if( !file_exists( $this->fileName ) )
			throw new RuntimeException( 'File "'.$this->fileName.'" is not existing.' );
		$this->data		= parse_ini_file( $this->fileName, true );
	}
932765
public function getPath($asArray = true)
    {
        $raw = $this->owner->{$this->pathAttribute};
        return $asArray ? $this->convertPathFromPgToPhp($raw) : $raw;
    }
986295
private function getArray($json) : array
    {
        $data = json_decode($json, true);
        if ($error = json_last_error() !== JSON_ERROR_NONE) {
            throw new RuntimeException(json_last_error_msg());
        }

        return $data;
    }