从 jsreport 访问 json 中的嵌套数组
accessing Nested arrays in json from jsreport
我正在尝试使用 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}}
为什么要经过两次?我想不通。
发现我不需要嵌套数组,所以这不再是问题。
我正在尝试使用 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}}
为什么要经过两次?我想不通。
发现我不需要嵌套数组,所以这不再是问题。