Closed fazibear closed 9 years ago
In this situation keys instead of "smth"
become "\"smth\""
.
Example:
storage[:test] = {}
puts storage[:test] # => {}
storage.reload
puts storage[:test] # => nil
Yes, it's intended, that way you can use anything as key, as is commong with Hash
.
It seems like something else is broken in the reloading.
So maybe it should use to_s
instead of to_json
twice ?
@data.each {|key, value|
io << key.to_s.to_json << ":" << value.to_json << ","
}
Maybe .to_json.to_s
.
Both .to_json.to_s
and .to_s.to_json
work. And you suggest first one is better :+1:
Merged.
I'm pretty sure to recall that was on purpose, because the storage keys can only be strings.