Open swt83 opened 11 years ago
I'm using this to patch the string before parsing:
// iterate thru string
$final = '';
$lines = explode("\n", $string);
foreach ($lines as $line)
{
// check for dash...
$trim = ltrim($line);
if (substr($trim, 0, 1) === '-')
{
// bump space
$line = ' '.$line;
}
// add back to string
$final .= $line."\n";
}
// return
return $final;
What you are seeing is that the original YAML you are feeding in is using compact in-line notation for block sequences. This was introduced in YAML 1.1. Spyc, being a pure PHP implementation, only supports a subset of YAML, which means it doesn't strictly adhere to any particular version of the spec.
That aside, it would be REALLY nice to have compact in-line notations read normally in Spyc - because most YAML emitters will dump in this format.
I've never used YAML before, and I am not familiar w/ the spec rules, but I need it for a certain project. In this project, I'm finding that SPYC doesn't parse multidimensional arrays properly in every case, but oddly if I add a space before every "-" character in the file it will parse correctly. Here is some sample YAML that I'm using as a test:
Does not work:
Works:
Maybe the file I'm using as my source is formatted incorrectly. Maybe there is a param in the class that I am missing that covers this.