I would like to get data from a Mysql dump in yaml (PHPMyAdmin), but data are not surrounded by quotation mark.
I have zipcode that can start by 0 and after parsing I get decimal version of octal value, in place of simple string.
How can I do to force Yaml parser not to do auto-mapping, or just get all data as they are string ?
Thanks
== UPDATE ==
2185:
id: 3274
civility: Mr
address: CROIX DES COMBES
zipcode: 04270
If your zipcode values are strings, which they probably should be in the database, and they are converted correctly to YAML, then they will be reconverted back into strings by Ruby’s YAML parser:
If we treat it as a string, it converts correctly.
If we treat it as an integer, it has its leading
0dropped, which I’d expect.In your sample:
zipcodeis a YAML integer. It should be enclosed inside quotes to preserve its “stringness”.Wikipedia’s YAML article has a nice example showing how data types are supposed to be disambiguated.
You can tweak all the instances of
zipcodein the YAML before parsing it doing something like: