Jochen Österreicher Jochen Österreicher - 1 year ago 172
JSON Question

swift 3 parse json array as key value

i have a json, which i parse as a dictionary. Now most is simply a key value pair like "title":{"this is the title"}. The one thing bugging me is a key value pair that has an array for value.


i do not want to use SwiftyJSON, since this is the only part i am unable to solve. What i need is to convert this value into an Array, which i can iterate. I had some approaches, they failed because they added new lines or stopped displaying äöü symbols.

Thank you in advance!

Answer Source
  • hashTags is an array of dictionaries with String keys and values, cast it to [[String:String]]
  • Iterate thru the array with a for loop and print all values for key name

    if let hashTags = json["hashTags"] as? [[String:String]] {
       for tag in hashTags {

It's assumed that json is the parent object which contains the key hashTags.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download