-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Unable to parse ruby generated yaml with unknown mappings #8562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Indeed, the YAML component does not implement the whole specification, but only a subset that is widely used for configuration files. YAML files like you mentioned are not parsed correctly by the current parser and there are no plans to implement this syntax. |
i guess we are missing support for http://www.yaml.org/spec/1.1/#tag%20shorthand/ (note this also exists in 1.2 but isn't listed as nicely in the spec so I am linking 1.1)? |
@fabpot but would you accept a patch that would implement this? (note I do not have time to work on this .. but someone else might ..) |
If someone can implement this without a big refactoring of the current code, and without adding a ton of code, I'm fine with it. |
👍 |
In my example I had the following YAML structure: ---
- - :custom_field_str_1
- Bemerkung 2
- - :custom_field_str_2
- Neues Feld
- - :custom_field_num_1
- Paletten
- - :custom_field_num_2
- Bemerkung 3 This is the way Rails resp. Active Record serializes it: The Symfony YAML
8000
component will fail: @coderofsalvatio suggested me to take a look at the PHP YAML Extension: Indeed this will correctely parse my YAML (coming from an entity column named $customFields): $parsed = yaml_parse($customFields);
var_dump($parsed);
array (size=4)
0 =>
array (size=2)
0 => string ':custom_field_str_1' (length=19)
1 => string 'Bemerkung 2' (length=11)
1 =>
array (size=2)
0 => string ':custom_field_str_2' (length=19)
1 => string 'Neues Feld' (length=10)
2 =>
array (size=2)
0 => string ':custom_field_num_1' (length=19)
1 => string 'Paletten' (length=8)
3 =>
array (size=2)
0 => string ':custom_field_num_2' (length=19)
1 => string 'Bemerkung 3' (length=11) Maybe this will help some other users like @bjoerne2 at the moment: Is this interesting for the refactoring too @lsmith77 @fabpot ? |
Does anybody know if Symfony 2.6 YAML |
no it won't. It is not related to the supported YAML features. As you can see in the PR you linked, it does not change the parsing itself, but only the way maps are returned after being parsed (and your example does not even use a map, but lists) |
covering the core spec of YAML should be a goal, covering as many of the optional features as possible is a nice to have. |
Closing as we will never support the whole spec and it seems that few people have this issue. |
I am generating a Yaml config file with rubys YAML::dump, and want to read the generated file with Symfonys Yaml-Component. However, YAML::dump adds some unwanted "object mapping" to some hashes, which causes the Symfony Parser to fail:
The
!map:Mash
causes the parsing to fail. Technically, this is probably no bug, this the designated object type Yaml is supposed to map the data to is unknown - but maybe it is a good idea to either mention this issue in the documentation, or provide some possibility to ignore/override it.Right now, my workaround is a pretty ugly one, I am removing it on the ruby side in the resulting yaml string: https://github.com/till/easybib-cookbooks/blob/bibcd/bibcd/providers/app.rb#L12 - and I would love to do it somewhat cleaner and error prone.
Any thoughts here?
The text was updated successfully, but these errors were encountered: