iOS swift,从 JSON 数组中检索和删除特定对象 Parse.com

标签 ios swift parse-platform

当我们有JSON数据时,如何在parse.com中查询和删除?

我有一个 JSON 数组(如下所示)存储在 Parse.com 数据库中,数据库键为“JSONArray”,解析类为“Test”。现在我想删除所有包含特定公司名称的项目。

例如:我想删除与公司名称“james”相关的所有内容。即下面 JSON 的索引 1。

 (
    {
    amount = "20.8";
    companyName = valentino;
    optionalNoteText = "This is test 1 ";
    sPreferenceStatus =         (
                    (
            0,
            0,
            0,
            0,
            0
        )
    );
},
    {
    amount = "52";
    companyName = james;
    optionalNoteText = "This is test 2";
    sPreferenceStatus =         (
                    (
            0,
            1,
            0,
            1,
            0
        )
    );
},
    {
    amount = "10.4";
    companyName = nikki;
    optionalNoteText = “This is test 3”;
    sPreferenceStatus =         (
                    (
            1,
            1,
            1,
            1,
            0
        )
    );
},
    {
    amount = "9.35";
    companyName = jason;
    optionalNoteText = “Test is test 4;
    sPreferenceStatus =         (
                    (
            1,
            0,
            0,
            1,
            0
        )
    );
},
    {
    amount = "8.32";
    companyName = vicky;
    optionalNoteText = "This is test 5";
    sPreferenceStatus =         (
                    (
            0,
            1,
            1,
            0,
            0
        )
    );
}



var findreceivedPostData:PFQuery = PFQuery(className: "Test")
    findreceivedPostData.orderByDescending("createdAt")

//这就是我们通常过滤的方式,在本例中它只是 anArray = ["valentino", "jason", "james", "nikki"] 中的当前用户。

 findreceivedPostData.whereKey("anArray", containedIn: ["\(PFUser.currentUser()!.username!)"])

有人知道如何使用 JSON 吗?

最佳答案

如果您将 JSON 数据存储为字符串,则需要下载容器对象,修改 JSON 字符串,然后保存容器。或者,编写一个云代码函数来执行相同的操作。像这样将数据存储为文本并不是很有效,您应该将其建模为指针/关系和类。

关于iOS swift,从 JSON 数组中检索和删除特定对象 Parse.com,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31667963/

相关文章:

ios - SqlCommand 对象的构造函数和 Dispose 方法在 Mono 中是线程安全的吗?

ios - 解析 GeoPoint 限制

ios - 为 webView 添加分享功能 - iOS

android - 如何修复 (android.database.CursorWindowAllocationException) 崩溃

ios - Parse.com - 将指针从用户类设置为安装类

ios - 如何发送带有附件的GTLRGmail_Message

ios - 我可以在一个容器应用程序上创建两个自定义键盘吗

iOS,找不到合适的图像/缺少所需的代码签名

Swift - 实时更新标签

java - 异常: "No default Constructor provided" exception subclassing ParseObject