Load a JSON file, decode the data and save it to the $_content variable.

@param $pFile string File path
@param $pToArray bool Get result as array
@return Json
421501
public function loadFile($pFile, $pToArray = false)
    {
        $content = file_get_contents($pFile);
        if ($content !== false) {
            $this->_content = ($pToArray) ? json_decode($content, true) : json_decode($content);
        }

        return $this;
    }
1233770
public function load($path, $file)
  {
    $the_file = $path . '/' . $file;

    return json_decode($this->read_file($the_file), true);
  }
631739
protected function load( $file ) {
		if ( ! file_exists( $file ) ) {
			throw new JsonFileNotFoundException( 'The required ' . basename( $file ) . ' file is missing.' );
		}

		$contents = file_get_contents( $file );
		$json = json_decode( $contents, true );
		$json_error = json_last_error();

		if ( $json_error !== JSON_ERROR_NONE ) {
			throw new JsonFileInvalidException( 'The required ' . basename( $file ) . ' file is not valid JSON (error code ' . $json_error . ').' );
		}

		return $json;
	}
385853
protected function loadJsonFile( $fileName )
	{
		$json	= FS_File_Reader::load( $fileName );
		$array	= ADT_JSON_Converter::convertToArray( $json );
		foreach( $array as $sectionName => $sectionData )
			foreach( $sectionData as $key => $item )
				$this->pairs[$sectionName.".".$key]	= $item['value'];
	}
132763
public function load($pathToFile)
    {
        $config = [
            'data' => null,
            'extras' => [
                'isUpdated'  => false,
                'fileName'   => str_replace('\\', '/', $pathToFile),
                'fileExists' => file_exists($pathToFile)]
        ];

        $this->searchCache($pathToFile, $config);
        if (null === $config['data']) {
            $config['extras']['isUpdated'] = true;
            if (file_exists($pathToFile)) {
                switch (substr($pathToFile, strrpos($pathToFile, '.'))) {
                    case '.yml':
                        $config['data'] = Yaml::parse(file_get_contents($pathToFile));
                        break;

                    case '.json':
                        $data = file_get_contents($pathToFile);
                        $config['data'] = json_decode($data, true);
                        break;

                    default:
                        $config['data'] = require $pathToFile;
                }

                $this->saveCache($config, $pathToFile, $this->cacheDepth);
            } else {
                $config['data'] = [];
            }
        } else {
        }
        return $config;
    }
707574
protected function load()
    {
        $decoder = new JsonDecoder();

        $this->json = file_exists($this->path)
            ? (array) $decoder->decodeFile($this->path, $this->schemaPath)
            : array();

        if (isset($this->json['_order'])) {
            $this->json['_order'] = (array) $this->json['_order'];

            foreach ($this->json['_order'] as $path => $entries) {
                foreach ($entries as $key => $entry) {
                    $this->json['_order'][$path][$key] = (array) $entry;
                }
            }
        }

        // The root node always exists
        if (!isset($this->json['/'])) {
            $this->json['/'] = null;
        }

        // Make sure the JSON is sorted in reverse order
        krsort($this->json);
    }
310234
public function loadString($pString, $pToArray = false)
    {
        $this->_content = ($pToArray) ? json_decode($pString, true) : json_decode($pString);
        return $this;
    }
631420
private JsonArray loadJSONArray(File jsonFile) throws JsonParseException {

        logger.entering(jsonFile);

        String jsonTxt;

        try {
            jsonTxt = FileUtils.readFileToString(jsonFile, "UTF-8");
        } catch (IOException e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
            throw new ReporterException(e);
        }

        StringBuilder completeJSONTxt = new StringBuilder("[");
        completeJSONTxt.append(StringUtils.removeEnd(jsonTxt, ",\n"));
        completeJSONTxt.append("]");
        JsonArray testObjects = (new JsonParser()).parse(completeJSONTxt.toString()).getAsJsonArray();

        logger.exiting(testObjects);

        return testObjects;
    }
303878
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
	{
		$lineEnding = ini_get('auto_detect_line_endings');
		ini_set('auto_detect_line_endings', true);

		// Open file
		$this->_openFile($pFilename);
		if (!$this->_isValidFormat()) {
			fclose ($this->_fileHandle);
			throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
		}
		$fileHandle = $this->_fileHandle;

		// Skip BOM, if any
		$this->_skipBOM();

		// Create new PHPExcel object
		while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
			$objPHPExcel->createSheet();
		}
		$sheet = $objPHPExcel->setActiveSheetIndex($this->_sheetIndex);

		$escapeEnclosures = array( "\\" . $this->_enclosure,
								   $this->_enclosure . $this->_enclosure
								 );

		// Set our starting row based on whether we're in contiguous mode or not
		$currentRow = 1;
		if ($this->_contiguous) {
			$currentRow = ($this->_contiguousRow == -1) ? $sheet->getHighestRow(): $this->_contiguousRow;
		}

		// Loop through each line of the file in turn
		while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
			$columnLetter = 'A';
			foreach($rowData as $rowDatum) {
				if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
					// Unescape enclosures
					$rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum);

					// Convert encoding if necessary
					if ($this->_inputEncoding !== 'UTF-8') {
						$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->_inputEncoding);
					}

					// Set cell value
					$sheet->getCell($columnLetter . $currentRow)->setValue($rowDatum);
				}
				++$columnLetter;
			}
			++$currentRow;
		}

		// Close file
		fclose($fileHandle);

		if ($this->_contiguous) {
			$this->_contiguousRow = $currentRow;
		}

		ini_set('auto_detect_line_endings', $lineEnding);

		// Return
		return $objPHPExcel;
	}
100194
private static SFPair<OcspResponseCacheKey, SFPair<Long, String>>
  decodeCacheFromJSON(Map.Entry<String, JsonNode> elem) throws IOException
  {
    long currentTimeSecond = new Date().getTime() / 1000;
    byte[] certIdDer = Base64.decodeBase64(elem.getKey());
    DLSequence rawCertId = (DLSequence) ASN1ObjectIdentifier.fromByteArray(certIdDer);
    ASN1Encodable[] rawCertIdArray = rawCertId.toArray();
    byte[] issuerNameHashDer = ((DEROctetString) rawCertIdArray[1]).getEncoded();
    byte[] issuerKeyHashDer = ((DEROctetString) rawCertIdArray[2]).getEncoded();
    BigInteger serialNumber = ((ASN1Integer) rawCertIdArray[3]).getValue();

    OcspResponseCacheKey k = new OcspResponseCacheKey(
        issuerNameHashDer, issuerKeyHashDer, serialNumber);

    JsonNode ocspRespBase64 = elem.getValue();
    if (!ocspRespBase64.isArray() || ocspRespBase64.size() != 2)
    {
      LOGGER.debug("Invalid cache file format.");
      return null;
    }
    long producedAt = ocspRespBase64.get(0).asLong();
    String ocspResp = ocspRespBase64.get(1).asText();

    if (currentTimeSecond - CACHE_EXPIRATION_IN_SECONDS <= producedAt)
    {
      // add cache
      return SFPair.of(k, SFPair.of(producedAt, ocspResp));
    }
    else
    {
      // delete cache
      return SFPair.of(k, SFPair.of(producedAt, (String) null));
    }
  }
1083134
def loadjson(filename, asnparrays=False):
    
    with open(filename) as f:
        data = json.load(f)
    if asnparrays:
        for key, value in data.items():
            if type(value) is list:
                data[key] = np.asarray(value)
            if type(value) is dict:
                for key2, value2 in value.items():
                    if type(value2) is list:
                        data[key][key2] = np.asarray(value2)
    return data
788603
function load($file,$parse='php'){
        if(!file_exists($file)){
            //从模块内的配置文件开始查找，如果文件存在则替换，否则return[]
            $info = pathinfo($file);
            if($info['dirname']==='.'&&$file!=($info['dirname'].DIRECTORY_SEPARATOR.$info['basename'])){
                foreach ([APP_PATH.DIRECTORY_SEPARATOR.'Common/Config'] as $dir){
                    if(file_exists($dir.DIRECTORY_SEPARATOR.$info['basename'])){
                        $file=$dir.DIRECTORY_SEPARATOR.$info['basename'];
                    }
                }
            }
            if(!file_exists($file)){
                return [];
            }
        }
        $ext  = pathinfo($file,PATHINFO_EXTENSION);
        switch($ext){
            case 'php':
                return include $file;
            case 'ini':
                return parse_ini_file($file);
            case 'yaml':
                return yaml_parse_file($file);
            case 'xml':
                return (array)simplexml_load_file($file);
            case 'json':
                return json_decode(file_get_contents($file), true);
            default:
                if(function_exists($parse)){
                    return $parse($file);
                }else{
                    L(E('_NOT_SUPPORT_').':'.$ext);
                }
        }
    }
79730
private function _createFile($pFile)
    {
        $pathInfo = pathinfo($pFile);

        $dir = $pathInfo['dirname'];
        if (! DirecoryData::create($dir)) {
            throw new Exception("Unable to create the cache directory '$dir'");
        }

        if (! is_readable($pFile) and ! FileData::create($pFile, self::DEFAULT_CONTENT)) {
            throw new Exception("Unable to create the cache file '$pFile'");
        }

        return $this;
    }
1132700
public static function decode($json, array $context = [])
    {
        $context = array_merge(static::$defaultDecodeContext, $context);

        return static::decodeData($json, $context);
    }
76227
public static function saveJson($path, $file, array $data)
    {
        $fp = fopen(self::cleanPath($path) . self::DS . $file . '.json', 'w');
        fwrite($fp, json_encode($data));

        return fclose($fp);
    }
1267455
public function stream_open( $pPath, $pMode, $pFlags, &$pOpenedPath )
	{
		if( 'r' !== $pMode && 'rb' !== $pMode )
		{
			\trigger_error(
				 $pPath . ': failed to open stream: HTTP wrapper does not support writable connections'
			);
			return FALSE;
		}

		// TODO: Find out what needs to happen when the path is already open. I may have misunderstood here.

		$this->url = \parse_url( $pPath );
		//
		if ( static::$saveFilePersist )
		{
			++static::$persistFileIncrement;
		}
		// See if we have a save file for this request.
		$localFile = $this->getSaveFile();
		// Load from local file, or make an internet request.
		if ( \file_exists($localFile) )
		{
			$this->resourceType = static::RESOURCE_TYPE_FILE;
			$this->resource = \fopen( $localFile, 'r' );
		}
		else
		{
			$this->resourceType = static::RESOURCE_TYPE_SOCKET;
			$timeout = ini_get( 'default_socket_timeout' );
			$this->ssl = ( \strcmp($this->url['scheme'], 'https') === 0 );
			$port = ( $this->ssl ) ? 443 : 80;
			// When port is specified, use that.
			if ( \array_key_exists('port', $this->url) )
			{
				$port = ( int ) $this->url[ 'port' ];
			}

			// When context options are set, use them.
			$options = \stream_context_get_options( $this->context );
			$httpOptions = NULL;
			if ( \array_key_exists('http', $options) )
			{
				$httpOptions = $options['http'];
				$timeout = array_key_exists('timeout', $httpOptions) ? $httpOptions['timeout'] : $timeout;
			}

			if ( $this->ssl ) // HTTPS
			{
				$remoteSocket = sprintf('ssl://%s:%d', $this->url['host'], $port );
				$this->resource = \stream_socket_client(
					$remoteSocket,
					$errorNo,
					$errorStr,
					$timeout,
					( $pFlags ?: \STREAM_CLIENT_CONNECT ),
					$this->context
				);

				if ( $errorNo > 0 ) {
					\trigger_error($errorStr);
				}
			}
			else // HTTP
			{
				// Init socket resource.
				$this->resource = \socket_create( \AF_INET, \SOCK_STREAM, \SOL_TCP );
				if ( !is_resource( $this->resource ) )
				{
					\trigger_error( 'Unable to connect to ' . $this->url[ 'host' ] );
					return FALSE;
				}

				// Attempt to connect.
				$isConnected = @\socket_connect( $this->resource, $this->url[ 'host' ], $port );
				if ( !$isConnected )
				{
					$this->triggerSocketError();
					return FALSE;
				}
			}

			// TODO: figure out when to set blocking mode.
			if ( $pFlags !== 0 ) {
				// TODO: Handle flags.
			}

			$request = $this->buildRequest( $httpOptions );
			$lengthToWrite = \strlen( $request );
			$lengthWritten = 0;
			// Send the request.
			do
			{
				if ( $this->ssl )
				{
					$lengthWritten += \fputs( $this->resource, $request );
				}
				else
				{
					$lengthWritten += \socket_write( $this->resource, $request );
				}

				if ( $lengthWritten >= $lengthToWrite ) {
					break;
				}
				else
				{
					echo( 'still need to write this much to the socket: ' . ($lengthToWrite - $lengthWritten) . "\n" );
				}

			} while ( $lengthWritten < $lengthToWrite );
		}

		$this->populateResponseHeaders();

		// Indicate that we have successfully opened the path.
		$pOpenedPath = $pPath;

		return TRUE;
	}
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 : [];
    }