# YAML.load(some\_string) doesn't return hash?

**URL:** <https://www.ruby-forum.com/t/yaml-load-some-string-doesnt-return-hash/66149>\
**Category:** Rails\
**Created:** [August 23, 2006, 5:52pm UTC](https://www.ruby-forum.com/t/yaml-load-some-string-doesnt-return-hash/66149 "2006-08-23T17:52:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9fc348/32.png) [@gbh](https://www.ruby-forum.com/u/gbh)\
**Post date:** [August 23, 2006, 5:52pm UTC](https://www.ruby-forum.com/t/yaml-load-some-string-doesnt-return-hash/66149/1 "2006-08-23T17:52:50Z")

</div>

A small problem here. As per documentation on  
[http://corelib.rubyonrails.org/classes/YAML.html](http://corelib.rubyonrails.org/classes/YAML.html) YAML.load(string)  
should just return a hash. However on my windows machine it returns  
something like this:

#\<YAML::Syck::DomainType:0x36d5038  
@domain=“[yaml.org](http://yaml.org),2002”,  
@type\_id=“map:HashWithIndifferentAccess”,  
@value=  
{“key”=\>“value”,  
“key”=\>“value”,  
“key”=\>“value”,  
“key”=\>“value”,  
}\>

Obviously, on windows machine I have to do something like  
YAML.load(something).value[‘key’] to get something. On Linux box .value  
method will fail as we only get a simple hash there.

Any idea what is goin on? A bug?

---

<div class="post-metadata">

**Author:** ![gbh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9fc348/32.png) [@gbh](https://www.ruby-forum.com/u/gbh)\
**Post date:** [August 23, 2006, 8:42pm UTC](https://www.ruby-forum.com/t/yaml-load-some-string-doesnt-return-hash/66149/2 "2006-08-23T20:42:18Z")

</div>

Can we see the YAML you’re trying to load?

Jason

---

<div class="post-metadata">

**Author:** ![gbh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9fc348/32.png) [@gbh](https://www.ruby-forum.com/u/gbh)\
**Post date:** [November 1, 2006, 8:32pm UTC](https://www.ruby-forum.com/t/yaml-load-some-string-doesnt-return-hash/66149/3 "2006-11-01T20:32:47Z")

</div>

Oleg Kh wrote:

> A small problem here. As per documentation on  
> [http://corelib.rubyonrails.org/classes/YAML.html](http://corelib.rubyonrails.org/classes/YAML.html) YAML.load(string)  
> should just return a hash. However on my windows machine it returns  
> something like this:
> 
> #\<YAML::Syck::DomainType:0x36d5038  
> @domain=“[yaml.org](http://yaml.org),2002”,  
> @type\_id=“map:HashWithIndifferentAccess”,  
> @value=  
> {“key”=\>“value”,  
> “key”=\>“value”,  
> “key”=\>“value”,  
> “key”=\>“value”,  
> }\>
> 
> Obviously, on windows machine I have to do something like  
> YAML.load(something).value[‘key’] to get something. On Linux box .value  
> method will fail as we only get a simple hash there.
> 
> Any idea what is goin on? A bug?

Now, I am seeing this problem, too, but in serializing.

Specifically, I have a field that’s serialized in my model. This works  
fine going back and forth to a hash in Locomotive in development. But,  
in production on DreamHost, the deseralization ends up like this:

!ruby/object:YAML::Syck::DomainType  
domain: [yaml.org](http://yaml.org),2002  
type\_id: map:HashWithIndifferentAccess  
value:  
key1: “value1”  
key2: “value2”

Thus, of course, I can’t use the hash methods. And Rails then generates  
errors like “undefined method `include?’ for  
#YAML::Syck::DomainType:0x407fb584”

I’m using Rails 1.1.6, and so is DreamHost. Does anyone have any ideas  
what’s going on?

-Paul
