fromJson() public method

Converts JSON to an implementation-specific data structure.
public fromJson ( mixed $jsonData, array $options = [] ) : mixed
$jsonData mixed The JSON data. Use a {@link JsonDecoder} to convert a JSON string to this data structure
$options array Additional implementation-specific conversion options
return mixed The converted data
Ejemplo n.º 1
0
 /**
  * Loads a configuration file from a path.
  *
  * If the path does not exist, an empty configuration file is returned.
  *
  * @param string      $path       The path to the configuration file.
  * @param Config|null $baseConfig The configuration that the loaded
  *                                configuration will inherit its values
  *                                from.
  *
  * @return ConfigFile The loaded configuration file.
  *
  * @throws FileNotFoundException  If the file does not exist.
  * @throws ReadException          If the file cannot be read.
  * @throws InvalidConfigException If the file contains invalid configuration.
  */
 public function loadConfigFile($path, Config $baseConfig = null)
 {
     $json = $this->storage->read($path);
     $jsonData = $this->decode($json, $path);
     try {
         return $this->configFileConverter->fromJson($jsonData, array('path' => $path, 'baseConfig' => $baseConfig));
     } catch (ConversionFailedException $e) {
         throw new InvalidConfigException(sprintf('The JSON in %s could not be converted: %s', $path, $e->getMessage()), 0, $e);
     }
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function fromJson($jsonData, array $options = array())
 {
     $this->assertObject($jsonData);
     $this->assertVersionIsset($jsonData);
     $this->assertVersionSupported($jsonData->version);
     if ($jsonData->version !== $this->currentVersion) {
         $this->migrationManager->migrate($jsonData, $this->currentVersion);
     }
     return $this->innerConverter->fromJson($jsonData, $options);
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function fromJson($jsonData, array $options = array())
 {
     $this->validate($jsonData);
     return $this->innerConverter->fromJson($jsonData, $options);
 }