+ [NSJSONSerialization ensureObjectForKey:inDictionary:hasExpectedType:nullAllowed:]中的断言失败

时间:2013-10-16 19:06:42

标签: box-api

我正在使用box-ios-sdk-v2(v1.1.0),当我打电话时:

[[BoxCocoaSDK sharedSDK].foldersManager folderInfoWithID:BoxAPIFolderIDRoot
                                          requestBuilder:nil
                                                 success:folderSuccess
                                                 failure:failure];

我得到断言失败:

*** Assertion failure in +[NSJSONSerialization ensureObjectForKey:inDictionary:hasExpectedType:nullAllowed:], ~/MyApp/Pods/box-ios-sdk-v2/BoxSDK/Categories/NSJSONSerialization+BoxAdditions.m:27
An uncaught exception was raised
+[NSJSONSerialization(BoxAdditions) ensureObjectForKey:inDictionary:hasExpectedType:nullAllowed:]: Unexpected JSON null when extracting key modified_at from dictionary {
    "content_created_at" = "<null>";
    "content_modified_at" = "<null>";
    "created_at" = "<null>";
    "created_by" =     {
        id = "";
        login = "";
        name = "";
        type = user;
    };
    description = "";
    etag = "<null>";
    "folder_upload_email" = "<null>";
    id = 0;
    "item_collection" =     {
        entries =         (
                        {
                etag = 0;
                id = 1092326452;
                name = CSS;
                "sequence_id" = 0;
                type = folder;
            },
                        {
                etag = 1;
                id = 680411078;
                name = New;
                "sequence_id" = 1;
                type = folder;
            },
                        {
                etag = 2;
                id = 8224096128;
                name = ".apdisk";
                "sequence_id" = 2;
                sha1 = e8389b6e4307a798b0811cabc94144ce381b3312;
                type = file;
            }
        );
        limit = 100;
        offset = 0;
        order =         (
                        {
                by = type;
                direction = ASC;
            },
                        {
                by = name;
                direction = ASC;
            }
        );
        "total_count" = 3;
    };
    "item_status" = active;
    "modified_at" = "<null>";
    "modified_by" =     {
        id = 181198661;
        login = "grigutis@iu.edu";
        name = "John Grigutis";
        type = user;
    };
    name = "All Files";
    "owned_by" =     {
        id = 181198661;
        login = "grigutis@iu.edu";
        name = "John Grigutis";
        type = user;
    };
    parent = "<null>";
    "path_collection" =     {
        entries =         (
        );
        "total_count" = 0;
    };
    "purged_at" = "<null>";
    "sequence_id" = "<null>";
    "shared_link" = "<null>";
    size = 289;
    "trashed_at" = "<null>";
    type = folder;
}

这是我帐户的问题(modified_at真的不应该为null)或SDK吗?如果这是我的帐户,我该如何解决?

1 个答案:

答案 0 :(得分:1)

我是Box iOS SDK的维护者。感谢错误报告!根文件夹是Box上的特殊文件夹。根文件夹是实际不存在的“虚拟文件夹”(这解释了为什么它们在所有用户帐户中的ID始终为0)。由于根文件夹(和垃圾文件夹)是虚拟文件夹,因此我们不会跟踪它们的某些元数据,例如modified_at时间戳。

root / trash文件夹可能为null的字段列表:

  • sequence_id
  • ETAG
  • created_at
  • modified_at
  • trashed_at
  • purged_at
  • content_created_at
  • content_modified_at
  • shared_link

我已经整理了一个补丁来抑制这些Null并将它们转换为nil。 (我不想仅为root / trash文件夹的特殊情况将所有访问者转换为id返回类型。)https://github.com/box/box-ios-sdk-v2/pull/47

一旦合并了这个提交,我们就会删除一个bug修复版。

我们应该记录这种边缘案例/特殊情况行为。我会让我们的文档团队知道。