我从第一眼看就知道它听起来像重复的问题,但我认为不是......
我收到一个JSON数组:
var test1 = [] ;
Run Code Online (Sandbox Code Playgroud)
要么
var test2 = [{},{},{}] ; //This is empty
Run Code Online (Sandbox Code Playgroud)
我没有问题,发现是否test1是空的.
jQuery.isEmptyObject(test1)
Run Code Online (Sandbox Code Playgroud)
我的问题是test2...请注意,在某些情况下,test2可能返回如下内容:
var test2 = [{"a":1},{},{}] ; //All these are not empty
var test2 = [{},{"a":1},{}] ; //All these are not empty
var test2 = [{},{},{"a":1}] ; //All these are not empty
Run Code Online (Sandbox Code Playgroud)
上面的场景不应该被视为空.我试过使用.length但它没有帮助因为长度总是3 ...任何想法?
干杯.
我不确定为什么会这样:
main.cpp中:
int main(int argc, char * argv[]) {
Pwm_Info tf_info;
tf_info = get_pwm_info(library_data, motif_name);
}
Run Code Online (Sandbox Code Playgroud)
Gen.cpp
struct Pwm_Info {
std::string motif_name;
int width;
std::vector < double > pwm;
Pwm_Info(): motif_name(0),
width(0),
pwm(0) {}
}
TF_info;
Pwm_Info get_pwm_info(std::string library_data, std::string motif_name) {
std::vector < double > double_list;
strtk::parse(pwm_block, " \n\r", double_list);
std::cout << double_list.size() << std::endl;
Pwm_Info TF_info;
TF_info.motif_name = motif_name;
TF_info.width = n_width;
std::vector < double > * pointer;
std::vector < double > * pointer2;
pointer = & TF_info.pwm; …Run Code Online (Sandbox Code Playgroud)