Es ist ein Wörterbuch, das als JSONObject durch den folgenden Code formatiert ist:Wie "(" von einem JSONObject in swift entfernen
json = try NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions())
as! NSDictionary
Daten
{
"word": "detrimental",
"results": [
{
"definition": "(sometimes followed by `to') causing harm or injury",
"partOfSpeech": "adjective",
"synonyms": [
"damaging",
"prejudicial",
"prejudicious"
],
"similarTo": [
"harmful"
],
"derivation": [
"detriment"
]
}
],
"syllables": {
"count": 4,
"list": [
"det",
"ri",
"men",
"tal"
]
},
"pronunciation": {
"all": ",dɛtrə'mɛntəl"
},
"frequency": 2.77
}
bis ich versuche, Ausgabe der Daten mit einem Etikett
label.text = "\(json.valueForKeyPath("results.definition")!)"
Aber die Ausgabe wie folgt aussieht:
(
"(sometimes followed by `to') causing harm or injury"
)
Meine Frage ist, was ist der beste Weg, um die Ausgabe nur den Text ohne "()" zu zeigen?
Ist die einzige Möglichkeit, die JSON-Daten in NSString zu konvertieren und zu teilen? Ich hoffe, es gibt einen besseren Weg, wenn möglich
Mögliche Duplikat [entfernen Zeichen von NSString?] (Http://stackoverflow.com/questions/925780/remove-characters-from-nsstring) – ozgur