我正在使用WebSQL。我试图在异步块中添加数据,这使得数据无法插入。代码如下:
{"data":[{"id":"1","title":"- Parts I & II”,”CODE”:”xxx”,”product_url":"http:\/\/www.example.com","image_url":"http:\/\/ecx.images-example.com\/images\/I\/61ujIIMyW7L.jpg","price":"$25.00"},{"id":"2","title”:”AJDJDDJDr”,”Code”:”XX”,”product_url":"http:\/\/www.example.com","image_url":"http:\/\/dc.images-example.com\/images\/I\/41jFVZL72YL.jpg","price":"$10.99"}]}
JSON转储
#include<iostream>
using namespace std;
int main(){
int col, row,i;
int **array;
cout << "How many rows?\n";
cin >> row;
cout << "How many colomns\n";
cin >> col;
cout << "!!!!!!!!!!!!";
array = new int*[row];
for (int i = 0;i<row;i++){
array[i] = new int[col];
}
cout << "!!!!!!!!!!!!";
for( i=0; i<row; i++){
int x=1;
array[0][i]= x;;
x++;
}
cout << "!!!!!!!!!!!!";
cout << array[row][col];
for(i=0; i<row; i++){
delete [] array[i];
delete [] array;
}
return 0;
}
答案 0 :(得分:0)
试试这个;)
此循环条件出现问题:
for(var a = 0; a <= data.length; a++) {
^
此处您从0
开始并循环到data.length
所以要循环数组,因为数组索引从0
循环开始直到a <= data.length - 1
或a < data.length
for(var a = 0; a < data.length; a++) {
OR
for(var a=0; a <= (data.length - 1); a++) {
您可以像for
这样使用for...in
而不是for(var index in data){
alert(data[index].title);
}
循环:
;