【发布时间】:2025-12-08 11:35:01
【问题描述】:
如果它不是对称的,从这个结构中提取third level 元素的最干净的方法是什么:
yaml = [
{"Collection"=>[
{"Jeans"=>[
{"Trends"=>[
{"Building on basics"=>"Jeans"},
{"Unexpected pairings"=>"Jeans"},
{"Retro chic"=>"Jeans"} # extract me
]},
{"Styles"=>[
{"Straight Leg"=>"Straight Leg"},
{"Bootcut"=>"Bootcut"},
{"Trouser"=>"Trouser"},
{"Slim Leg"=>"Slim Leg"}
]},
{"Wash"=>[
{"Blues"=>"Blues"},
{"Black/Grey"=>"BlackGrey"},
{"Whites"=>"Summer Whites"},
{"Colors"=>"Colors"},
{"Resin"=>"Resin"}
]},
{"Details"=>[
{"Embroidered"=>"Embroidered"},
{"Tuxedo"=>"Tuxedo"},
{"Jeweled"=>"Jeweled"}
]}
]},
{"Bodyshapers"=>[
{"All"=>[
{"All"=>"BodyShapers"}
]}
]}
]},
{"Lift Tuck"=>nil},
{"Find Us" =>[
"By City",
"International Websites",
"Online Retailers"
]},
{"Your Stories"=>nil},
{"The Skinny"=>[
"Trends",
"Behind the Scenes",
"VIP Events",
"In the News",
"Win a Pair"
]}
]
【问题讨论】:
-
你能给出(一个样本)想要的结果吗?