【发布时间】:2019-08-14 19:06:48
【问题描述】:
我无法删除 Json 中的重复项。在下面的 Json 中,如果标题字段具有相同的值,我需要删除重复的节点。在名为“汽车”的 json 标题下方的 IN 重复了 3 次,我需要根据标题字段删除重复项。我关注了下面的stackoverflow链接,但没有解决我的问题。
Remove duplicate value in dart
实际的 Json:
{
"totalSize": 6,
"done": true,
"records": [{
"attributes": {
"type": "ContentVersion",
"url": "https://sampleUrl"
},
"Id": "123456",
"Title": "car",
"Team_Category__c": "Vehicle"
},
{
"attributes": {
"type": "ContentVersion",
"url": "https://sampleUrl"
},
"Id": "123456",
"Title": "car",
"Team_Category__c": "Vehicle"
},
{
"attributes": {
"type": "ContentVersion",
"url": "https://sampleUrl"
},
"Id": "123456",
"Title": "cycle",
"Team_Category__c": "Vehicle"
},
{
"attributes": {
"type": "ContentVersion",
"url": "https://sampleUrl"
},
"Id": "123456",
"Title": "aeroplane",
"Team_Category__c": "Vehicle"
},
{
"attributes": {
"type": "ContentVersion",
"url": "https://sampleUrl"
},
"Id": "123456",
"Title": "car",
"Team_Category__c": "Vehicle"
}
]
}
【问题讨论】:
-
你能描述一下与颤振的关系吗?如果您从数据库中获取此 json 作为响应,您只需读出您需要的数据,无需删除任何内容...
-
在我的数据库中,我遇到了一些具有相同名称的标题字段重复的问题。从移动应用程序 ios flutter 解析 json 时,我想使用 dart 中的 set 功能操作 Json 以删除重复项。下面的链接也类似于我的问题,但没有为我解决。 stackoverflow.com/questions/54087857/…
-
如果您将其转换为地图,则会删除重复项
-
能否分享如下示例代码 var newUniqueResponse = jsonResponseArray.map((records) => [records.title]);
标签: flutter