当我们有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/