You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are times when we need to load a YAML file but for various reasons, we do not want or care about the serialization/native dataclass conversions. We want to load the data in as a hash-tree object, as if the object classifier were not there.
Now it seems to me based on the long discussion related to the safe_load method, that safe_load does not, in fact, do what is requested here. It seems to me that several sane voices were a bit shuoted down in that discussion. But whatever.
What is needed is essentially to load YAML files as if they were dumb JSON files. As if the following code were implemented before the #load
I propose an implementation that is cleaner, that uses YAML.load() but based on the parser-personality. The personalities might be a kind of a "raw" mode and "native-object" mode. Raw mode only sees Hash, Array, String. Native-object mode also sees numeric, boolean (and..?)
I don't mind adding ways to customize loading, but not via global settings. Something similar to safe_load, but takes YAML and a class loader object should be enough to accomplish what you're looking for.
Personally, I'd just love to be able to pass an option to safe_load like raise: false. Instead of raising Psych::DisallowedClass, it could just leave the value as a string. In fact, I'd prefer that to be default behavior but maybe that's just me ;)
Passing a class loader would be awesome. The reverse - object to perform serialization would also be awesome. These two will allow to handle communication with non-fully compliant services.
There are times when we need to load a YAML file but for various reasons, we do not want or care about the serialization/native dataclass conversions. We want to load the data in as a hash-tree object, as if the object classifier were not there.
Now it seems to me based on the long discussion related to the
safe_load
method, thatsafe_load
does not, in fact, do what is requested here. It seems to me that several sane voices were a bit shuoted down in that discussion. But whatever.What is needed is essentially to load YAML files as if they were dumb JSON files. As if the following code were implemented before the
#load
Given the following YAML:
We get back from #load:
I propose an implementation that is cleaner, that uses
YAML.load()
but based on the parser-personality. The personalities might be a kind of a "raw" mode and "native-object" mode. Raw mode only sees Hash, Array, String. Native-object mode also sees numeric, boolean (and..?)Produces the inspected output, above. Whereas:
produces (subtly different):
The text was updated successfully, but these errors were encountered: