2

私はこの問題にかなり苦労しています。を文字列に保存しHashie::Mashましたが、それをハッシュとして復元するのに苦労しています。

文字列は次のとおりです。

"--- !map:Hashie::Mash \ncreated_at: Mon Jul 30 15:42:20 +0000 2012\nid: 229965155759439872\nid_str: \"229965155759439872\"\ntext: \"#streetart encore plus impressionnant de plus pr\\xC3\\xA8s http://t.co/lUUmXFYs\"\nsource: <a href=\"http://twicca.r246.jp/\" rel=\"nofollow\">twicca</a>\ntruncated: false\nin_reply_to_status_id: \nin_reply_to_status_id_str: \nin_reply_to_user_id: \nin_reply_to_user_id_str: \nin_reply_to_screen_name: \nuser: !map:Hashie::Mash \n id: 15762429\n id_str: \"15762429\"\n name: Cyroul\n screen_name: Cyroultwit\n location: Paris\n description: alias Cyril Rimbaud, explorateur de TAZ, creative Technologist, fondateur du laboratoire Curiouser, enseignant au CELSA et casseur de mythes publicitaires.\n url: http://www.cyroul.com\n protected: false\n followers_count: 7431\n friends_count: 1065\n listed_count: 481\n created_at: Thu Aug 07 12:05:21 +0000 2008\n favourites_count: 10\n utc_offset: 3600\n time_zone: Paris\n geo_enabled: false\n verified: false\n statuses_count: 12726\n lang: fr\n contributors_enabled: false\n is_translator: false\n profile_background_color: 1A1B1F\n profile_background_image_url: http://a0.twimg.com/profile_background_images/6800607/main-cyr.jpg\n profile_background_image_url_https: https://si0.twimg.com/profile_background_images/6800607/main-cyr.jpg\n profile_background_tile: false\n profile_image_url: http://a0.twimg.com/profile_images/2018752881/tete-etoiles-petit-128_normal.jpg\n profile_image_url_https: https://si0.twimg.com/profile_images/2018752881/tete-etoiles-petit-128_normal.jpg\n profile_link_color: 2FC2EF\n profile_sidebar_border_color: 181A1E\n profile_sidebar_fill_color: \"252429\"\n profile_text_color: \"666666\"\n profile_use_background_image: true\n show_all_inline_media: true\n default_profile: false\n default_profile_image: false\n following: false\n follow_request_sent: false\n notifications: false\ngeo: \ncoordinates: \nplace: \ncontributors: \nretweet_count: 0\nentities: !map:Hashie::Mash \n hashtags: \n - !map:Hashie::Mash \n text: streetart\n indices: \n - 0\n - 10\n urls: \n - !map:Hashie::Mash \n url: http://t.co/lUUmXFYs\n expanded_url: http://yfrog.com/nw86guqj\n display_url: yfrog.com/nw86guqj\n indices: \n - 51\n - 71\n user_mentions: []\n\nfavorited: false\nretweeted: false\npossibly_sensitive: false\n"

どうすればハッシュを取り戻すことができますか? よろしくお願いします!

4

1 に答える 1

2

YAML を使用して文字列をシリアル化したようです。次のようにデシリアライズできます。

require "yaml"
require "hashie"

YAML.load(your_string)
于 2012-07-30T17:05:09.563 に答える