请帮我在ruby中解析这个json:
"\"{\\\"Details\\\":[{\\\"WaybillNo\\\":\\\"11-17-657\\\",\\\"ShipperName\\\":\\\"Paritosh Singh\\\",\\\"ShipperAddress\\\":\\\"New Delhi, India\\\",\\\"ShipperMob\\\":\\\"0812944\\\",\\\"ConsigneeName\\\":\\\"SANDY\\\",\\\"ConsigneeAddress\\\":\\\"Mumbai India\\\",\\\"ConsigneeMob\\\":\\\"8355485\\\",\\\"Pieces\\\":\\\"1\\\"}]}\""
由于
答案 0 :(得分:5)
这看起来像JSON中的JSON:
require 'json'
string = "\"{\\\"Details\\\":[{\\\"WaybillNo\\\":\\\"11-17-657\\\",\\\"ShipperName\\\":\\\"Paritosh Singh\\\",\\\"ShipperAddress\\\":\\\"New Delhi, India\\\",\\\"ShipperMob\\\":\\\"0812944\\\",\\\"ConsigneeName\\\":\\\"SANDY\\\",\\\"ConsigneeAddress\\\":\\\"Mumbai India\\\",\\\"ConsigneeMob\\\":\\\"8355485\\\",\\\"Pieces\\\":\\\"1\\\"}]}\""
JSON.parse(JSON.parse(string))
#=> {
# "Details" => [
# [0] {
# "WaybillNo" => "11-17-657",
# "ShipperName" => "Paritosh Singh",
# "ShipperAddress" => "New Delhi, India",
# "ShipperMob" => "0812944",
# "ConsigneeName" => "SANDY",
# "ConsigneeAddress" => "Mumbai India",
# "ConsigneeMob" => "8355485",
# "Pieces" => "1"
# }
# ]
# }