我有一个像json这样的字符串:
[
"http:\/\/kashanmap.ir\/media\/k2\/galleries\/6861\/A.jpg",
"http:\/\/kashanmap.ir\/media\/k2\/galleries\/6861\/B.jpg",
"http:\/\/kashanmap.ir\/media\/k2\/galleries\/6861\/C.jpg"
]
我想将其转换为字符串(以逗号分隔):
http://kashanmap.ir/media/k2/galleries/6861/A.jpg,http://kashanmap.ir/media/k2/galleries/6861/B.jpg,http://kashanmap.ir/media/k2/galleries/6861/C.jpg
let json = JSON(stringLiteral: urls)
但在打印json
变量后,它会显示:
[
"http:\/\/kashanmap.ir\/media\/k2\/galleries\/3156\/A.jpg",
"http:\/\/kashanmap.ir\/media\/k2\/galleries\/3156\/B.jpg",
"http:\/\/kashanmap.ir\/media\/k2\/galleries\/3156\/C.jpg",
"http:\/\/kashanmap.ir\/media\/k2\/galleries\/3156\/D.jpg"
]
答案 0 :(得分:0)
尝试使用带逗号分隔符的连接函数
let stringArrayCities = ["Reno", "Austin", "Miami"]
let combinedstringArrayCitiesComma = stringArrayCities.joined(separator: ",")
print(combinedstringArrayCitiesComma)
// prints Reno,Austin,Miami