Json响应只获得了快速

时间:2017-03-22 06:49:36

标签: ios json swift swift3 nsjsonserialization

嗨我想从服务器获取儿子的响应,以下是我在使用邮递员时从服务器获得的响应

{
  "stories": [
{
  "image_url": "http://storybox.dk/wp-content/uploads/2016/11/Hansa.jpg",
  "name": "New story",
  "story_key": "ahJlfnN0b3J5Ym94LWJhY2tlbmRyEgsSBVN0b3J5GICAgIC8oYIKDA"
},
{
  "image_url": "http://storybox.dk/wp-content/uploads/2016/11/Hansa.jpg",
  "name": "Story of Foo the fox.",
  "story_key": "ahJlfnN0b3J5Ym94LWJhY2tlbmRyEgsSBVN0b3J5GICAgID4woQKDA"
}]
}

但是当我尝试将stories标签内的值作为数组获取时,它只获得一个值为
     self.StoryListArr =(reponsedict.value(forKey:" stories")as?NSArray)!

 (
   {
    "image_url" = "http://storage.googleapis.com/storybox-backend.appspot.com/5649391675244544/Screenshot_from_2017-03-16_113338.png";
    name = "Story of Foo";
    "story_key" = ahJlfnN0b3J5Ym94LWJhY2tlbmRyEgsSBVN0b3J5GICAgID4woQKDA;
   }
)

请建议如何处理

当我尝试打印响应dict时,它只显示一个值

{
stories =     (
            {
        "image_url" = "http://storage.googleapis.com/storybox-backend.appspot.com/5649391675244544/Screenshot_from_2017-03-16_113338.png";
        name = "Story of Foo";
        "story_key" = ahJlfnN0b3J5Ym94LWJhY2tlbmRyEgsSBVN0b3J5GICAgID4woQKDA;
    }
);
}

1 个答案:

答案 0 :(得分:1)

没有理由在Swift中使用NSArray。只需将对象转换为[Dictionary]。

For xx = 0 To BP.Width - 1
    For yy = 0 To BP.Width - 1
        Try

            Dim pixelColor As Color = BM.GetPixel(xx, yy)
            Dim lvi As ListViewItem = New ListViewItem

            lvi.Text = pixelColor.Name.ToString
            lvi.BackColor = pixelColor
            lvi.ForeColor = pixelColor
            ListView1.Items.Add(lvi)


        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    Next
Next