Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unexpected characters using YAML compact syntax #37788

Closed
@miceno

Description

@miceno

Symfony version(s) affected: 5.1.3

Description
I am reading the following YAML file, but I get a parser exception.

How to reproduce

This is the code:

        $config = Yaml::parseFile($ps_filepath, Yaml::PARSE_CONSTANT);

I am reading the following YAML file:

macro_scalar : /usr/local/fish
macro_list : [flounder, lobster, haddock]
macro_assoc : { 
  fish : [flounder, cod, haddock],
  shellfish : [scallop, crab, clam],
  other : [chicken, pig, cow]
}

override_value: "global"

This is the error:

Unexpected characters near "

override_value: "global"" at line 10.

If I move line override_value: "global" to the begining of the file, the problem dissapears:

override_value: "global"
macro_scalar : /usr/local/fish
macro_list : [flounder, lobster, haddock]
macro_assoc : { 
  fish : [flounder, cod, haddock],
  shellfish : [scallop, crab, clam],
  other : [chicken, pig, cow]
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions