【问题标题】:collectionMissingSeparator(0) Freddy JSON SwiftcollectionMissingSeparator(0) 弗雷迪 JSON 斯威夫特
【发布时间】:2017-11-25 01:18:22
【问题描述】:

所以... 1. JSON 文件:

{
    "image_id": "xDGMLGg3GCf5Ioiaf/OZJQ==",
    "request_id": "1509290346,180b0386-08cb-4332-9687-99009fb076c8",
    "time_used": 344,
    "faces": [
              {
              "landmark": {
              "mouth_upper_lip_left_contour2": {
              "y": 370,
              "x": 237
              },
              "mouth_upper_lip_top": {
              "y": 367,
              "x": 254
              },
              "mouth_upper_lip_left_contour1": {
              "y": 366,
              "x": 248
              }, ...

2。 Freddy 使用代码:

    var testx : String
    var testy : String

    init?(data: Data)
    {
        do
        {
            let json = try JSON(data: data)

            testx = try json.getString(at: "faces", "landmark", "mouth_upper_lip_left_contour2", "x")
            testy = try json.getString(at: "faces", "landmark", "mouth_upper_lip_left_contour2", "y")

            print("X= ",testx," and Y= ",testy,"inside of Freddy")
        }
        catch
        {
            print(error)
            return nil
        }
    }

看起来我做得很好,一切都在编译,但是......当我试图打印它时......结果是:“collectionMissingSeparator(0)”

来自tutorial

据我了解,我的代码中应该有一些“id”作为“at”参数......但是,地标不是按 ID 收集的,那么如何正确解析它?有人知道吗?

【问题讨论】:

    标签: ios json swift xcode


    【解决方案1】:

    我发现问题是:JSON 查询中没有足够的括号“}”。

    【讨论】:

      猜你喜欢
      • 2023-03-07
      • 2017-02-15
      • 2017-07-22
      • 2017-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多