How do I parse an array inside parsed JSON in Swift?

前端 未结 4 685
后悔当初
后悔当初 2020-12-08 10:32

I\'m using an API that returns JSON that looks like this

{
   \"boards\":[
      {
         \"attribute\":\"value1\"
      },
      {
         \"attribute\":         


        
4条回答
  •  [愿得一人]
    2020-12-08 10:50

    Dictionary access in Swift returns an Optional, so you need to force the value (or use the if let syntax) to use it.

    This works: parsedJSON["boards"]![0]

    (It probably shouldn't crash Xcode, though)

提交回复
热议问题