我正在搜索json对象数组:
let result = $.grep(jsonObjectArray, matchBothNames);
if (result.length == 1) { // unique match found
matchFound(result); // do stuff with the result
jsonObjectArray.remove(result); // how do I do something like this?
}
如何从正在搜索的数组中删除$ .grep()的结果?
对象不具有我可以使用的唯一唯一键/值。
编辑:
这是一个数组样本:
[
{
"First Name":"John",
"Last Name":"Smith",
"Block":"A",
"Mark":"75%",
"Student #":7724945
},
{
"First Name":"Jane",
"Last Name":"Doe",
"Block":"C,D",
"Mark":"56%",
"Student #":7715245
},
...
]
Doh,现在我看着它学号是唯一的。
答案 0 :(得分:1)
使用Array#indexOf()
和Array#splice()
#include<stdio.h>
#include<string.h>
int main(){
char str[80]="in this program we will find the longest keyword used so that we can";
int longest=0;
char word[25];
char longestword[25];
int i=0,j;
while(str[i]!='\0' && str[i]!=' '){
j=0;
while(str[i]!='\0' && str[i]!=' '){
word[j++] = str[i++];
}
word[j] = '\0';
if (strlen(word) > longest){
longest = strlen(str);
strcpy(longestword,longest);
}
if(str[i]==' '){
i++;
}
printf("longest word is :\n",longestword);
printf("length is:\n", longest);
return 0;
}
}