0

I'm using SwiftyJson and I wrote the code below,

for (_, value) in json["assets"] {
   print(value)
}

I got this result in my console what is I expect:

[
  {
    "urlImage" : "https:myFirstUrl",
    "page" : 1
  },
  {
    "urlImage" : "https:mySecondUrl",
    "page" : 2
  }]

But now I want to retrieve "urlImage" to assign this value in a constant.

jaykaydev
  • 141
  • 2
  • 9

1 Answers1

2

You can try this:

    for (_, value) in json["assets"] {
        for item in value.arrayValue {
            let url = item["urlImage"].stringValue
            print(url)
        }
    }

I hope it helps.

Rafaela Lourenço
  • 1,126
  • 16
  • 33