gpt4 book ai didi

ruby - Hashie::Mash 从字符串中恢复

转载 作者:太空宇宙 更新时间:2023-11-03 16:07:03 26 4
gpt4 key购买 nike

我在这个问题上很挣扎。我存储了一个 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"

我怎样才能取回哈希值?非常感谢!

最佳答案

看起来像你 serialized使用 YAML 的字符串。您可以像这样反序列化它:

require "yaml"
require "hashie"

YAML.load(your_string)

关于ruby - Hashie::Mash 从字符串中恢复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11726137/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com