Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function parse($options = [])
 {
     $options += ['exceptionsOnInvalidType' => false, 'objectSupport' => false, 'objectForMap' => false];
     $contents = $this->read();
     try {
         return Yaml::parse($contents, $options['exceptionsOnInvalidType'], $options['objectSupport'], $options['objectForMap']);
     } catch (Symfony\ParseException $e) {
         throw ParseException::castFromYaml($e);
     }
 }
Beispiel #2
0
 /**
  * Validates the syntax of a JSON string.
  *
  * @param string $json
  *
  * @throws ParseException
  */
 private static function validateSyntax($json)
 {
     $parser = new JsonParser();
     try {
         $parser->parse($json);
     } catch (ParsingException $e) {
         throw ParseException::castFromJson($e);
     }
     if (json_last_error() === JSON_ERROR_UTF8) {
         throw new ParseException('JSON parsing failed: ' . static::errorToString(JSON_ERROR_UTF8));
     }
 }