当我尝试使用 JSON.stringify 将下面的数组转换为字符串时,我只能看到空方括号。我尝试使用 console.log 进行调试,但我确实看到了要转换为字符串的数据,那么我在这里做错了什么?任何帮助都感激不尽!
function jsonSuccess( data ){
var jsonArr = new Array();
for( var i = 0; i < data.length; i++ ){
var shipInfo = new Array();
var shipRows = new Array();
$.each( data[i], function( key, value ){
if ( key == "EniNumber" ) {
shipInfo['E'] = value;
//console.log( shipInfo.E );
}
if ( key == "Name" ) {
shipInfo['N'] = value;
}
if ( key == "StartDate" ) {
shipInfo['S'] = value;
}
if ( key == "Rows" ) {
$.each( value, function( subKey, subValue ){
var rowContent = {
"T": subValue.T,
"X": subValue.X,
"Y": subValue.Y,
"D": subValue.D
}
shipRows.push( rowContent );
});
shipInfo['R'] = shipRows;
}
});
jsonArr[i] = shipInfo;
var myJsonString = JSON.stringify(jsonArr);
console.log(myJsonString);
}
}