From: mike@... (Mike Stok) Date: 2004-02-16T01:15:04+09:00 Subject: Re: YAML and quoted strings In article , Marek Janukowicz wrote: >How can I store/load a quoted string using YAML? The problem is, YAML >removes quotes when loading a file and I need to know whether the string >was quoted or not. The only way I have found so far is to use "'some >string'", but this is a bit ugly for me. It depends what you mean by a quoted string. If you mean a string containing quotes then YAML handles them just fine, for instance #!/usr/bin/env ruby require 'yaml' FILE_NAME = 'test.yml' hash = { 'key1' => %w{ 'foo' "bar" O'Brien } } puts "storing: #{hash.inspect}" File.open(FILE_NAME, 'w') do |f| f << hash.to_yaml end File.open(FILE_NAME) do |f| retrieved = YAML.load(f) puts "retrieved: #{retrieved.inspect}" puts "test element: #{retrieved['key1'][0]}" end produces this output: storing: {"key1"=>["'foo'", "\"bar\"", "O'Brien"]} retrieved: {"key1"=>["'foo'", "\"bar\"", "O'Brien"]} test element: 'foo' and the content of test.yml is --- key1: - "'foo'" - "\"bar\"" - "O'Brien" Without a little more context it is difficult to go much further. Hope this helps, Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA