我尝试使用jsrender引擎和{{for}}语句解析jsreport中的嵌套数组,但由于某种原因,它会通过araay两次。这是我的json数据:
"recordsOnFile": "4",
"invalidRecordsOnFile": "3",
"invalidRecordError": [
{"row": "2"},{"error": [
{"record": "In the field DateOfBirth."},{"record": "converting 0sass to type: m/d/yyyy."}
]
},
{"row": "3"},{"error": [
{"record": "in the field IsRehired"},{"record": "converting 11 to type: boolean."}
]
},
{"row": "4"},{"error": [
{"record": "Invalid Ethnicity Code"}
]
}
],
"numberNewRecords": "0",
"newRecords": [
{"nrecord": "0"}
],
"numberUpdatedRecords": "1",
"updatedRecords": [
{"updatedRowNumber": "5"},{"updateRowInfo": "Casper1003 Harper5003"}
]
}
这是我解析嵌套数组的jsreport:
<div class="textLeft" id="showInvalidRecord">
{{for invalidRecordError}}
<div class="textLeftIndent">Row Number: {{:row}}</div>
<div class="textLeftIndent">Error(s): {{for error}}{{:record}} : {{/for}}</div>
{{/for}}
为什么要经历两次?我无法弄清楚这一点。
答案 0 :(得分:1)
发现我不需要嵌套数组,所以这不再是一个问题。