Ruby: преобразование вложенного хеша Ruby в не вложенный

Прямо сейчас у меня есть вызов сервера, возвращающий следующий хэш Ruby:

{
  "id"=>"-ct",
  "factualId"=>"",
  "outOfBusiness"=>false,
  "publishedAt"=>"2012-03-09 11:02:01",
  "general"=>{
    "name"=>"A Cote",
    "timeZone"=>"EST",
    "desc"=>"À Côté is a small-plates restaurant in Oakland's charming
            Rockridge district. Cozy tables surround large communal tables in both
            the main dining room and on the sunny patio to create a festive atmosphere.
              Small plates reflecting the best of seasonal Mediterranean cuisine are served
            family-style by a friendly and knowledgeable staff.\nMenu items are paired with
            a carefully chosen selection of over 40 wines by the glass as well as a highly
            diverse bottled wine menu. Specialty drinks featuring fresh fruits, rare
            botaniques and fine liqueurs are featured at the bar.",
    "website"=>"http://acoterestaurant.com/"
  },
  "location"=>{
    "address1"=>"5478 College Ave",
    "address2"=>"",
    "city"=>"Oakland",
    "region"=>"CA",
    "country"=>"US",
    "postcode"=>"94618",
    "longitude"=>37.84235,
    "latitude"=>-122.25222
  },
  "phones"=>{
    "main"=>"510-655-6469",
    "fax"=>nil
  },
  "hours"=>{
    "mon"=>{"start"=>"", "end"=>""},
    "tue"=>{"start"=>"", "end"=>""},
    "wed"=>{"start"=>"", "end"=>""},
    "thu"=>{"start"=>"", "end"=>""},
    "fri"=>{"start"=>"", "end"=>""},
    "sat"=>{"start"=>"", "end"=>""},
    "sun"=>{"start"=>"", "end"=>""},
    "holidaySchedule"=>""
  },
  "businessType"=>"Restaurant"
}

Он имеет несколько вложенных атрибутов, таких как:

"wed"=>{"start"=>"", "end"=>""}

Мне нужно преобразовать этот объект в неопубликованный хеш в Ruby. В идеале я хотел бы определить, является ли атрибут вложенным, и ответить соответствующим образом, т.е. когда он определяет атрибут & apos;wed& APOS; вложенный, он извлекает свои данные и сохраняет их в полях & apos;wed-start& APOS; и & apos;wed-endили что-то подобное.

Кто-нибудь есть какие-либо советы о том, как начать?

Ответы на вопрос(4)

Ваш ответ на вопрос