私はこのようなハッシュに会います
{"num"=>"219", "id"=>"219", "name"=>"219", "key"=>"", "ps"=>["ˈɑ:bitrəri", "ˈɑrbɪˌtrɛri"], "sent"=>[{"orig"=>"\nHe makes unpredictable, decisions.\n", "trans"=>"\his decision is very hard to understand \n"}, {"orig"=>"\nYou can make an choice.\n", "trans"=>"\n you can chose randomly。\n"}]}
このハッシュの一部を印刷したいだけです。
私の解決策は
key = ['key','ps','sent']
key.each{|key| key == 'sent' ? (p server_config["sent"].to_s) : (p server_config[key])}
うまくいきません。このような2レベルのハッシュプリント
[{\"orig\"=>\"\\nAs soon as he kicked the bucket, he started to become famous.\\n\", \"trans\"=>\"\\nhe die and he became famous \\n\"}, ]"
この2レベルハッシュをうまく印刷する方法
以下のような出力が必要です。
As soon as he kicked the bucket, he started to become famous.
he die and he became famous.