Ruby: Konvertiert einen verschachtelten Ruby-Hash in einen nicht verschachtelten

Im Moment habe ich einen Serveraufruf, der den folgenden Ruby-Hash zurückwirft:

{
  "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"
}

Es hat mehrere Attribute, die verschachtelt sind, wie zum Beispiel:

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

Ich muss dieses Objekt in Ruby in einen nicht verschachtelten Hash konvertieren. Im Idealfall möchte ich erkennen, ob ein Attribut verschachtelt ist, und entsprechend antworten, I.E. wenn es das Attribut bestimmtwed'ist verschachtelt, holt seine Daten heraus und speichert in den Feldern'wed-start' und 'wed-end', oder etwas ähnliches.

Hat jemand Tipps für den Einstieg?

Antworten auf die Frage(4)

Ihre Antwort auf die Frage